예제 #1
0
        public TwilioPackager()
        {
            var configRepo = ObjectFactory.GetInstance<IConfigRepository>();
            //this will be overridden by Azure settings with the same name, on RC, Staging, and Production
            string accountSID = configRepo.Get(AccountSIDWebConfigName);
            string accountAuthKey = configRepo.Get(AuthTokenWebConfigName);
            _twilioFromNumber = configRepo.Get(FromNumberWebConfigName);

            if (String.IsNullOrEmpty(accountSID))
                throw new ArgumentNullException(AccountSIDWebConfigName, @"Value must be set in web.config");

            if (String.IsNullOrEmpty(accountAuthKey))
                throw new ArgumentNullException(AuthTokenWebConfigName, @"Value must be set in web.config");

            if (String.IsNullOrEmpty(_twilioFromNumber))
                throw new ArgumentNullException(FromNumberWebConfigName, @"Value must be set in web.config");

            _twilio = ObjectFactory.GetInstance<ITwilioRestClient>();
            _twilio.Initialize(accountSID, accountAuthKey);
        }
예제 #2
0
        /// <summary>
        /// read
        /// </summary>
        /// <param name="options"> Read Trunk parameters </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of Trunk </returns>
        public static async System.Threading.Tasks.Task <ResourceSet <TrunkResource> > ReadAsync(ReadTrunkOptions options,
                                                                                                 ITwilioRestClient client = null)
        {
            client = client ?? TwilioClient.GetRestClient();
            var response = await client.RequestAsync(BuildReadRequest(options, client));

            var page = Page <TrunkResource> .FromJson("trunks", response.Content);

            return(new ResourceSet <TrunkResource>(page, options, client));
        }
예제 #3
0
        /// <summary>
        /// delete
        /// </summary>
        /// <param name="pathSid"> The sid </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> A single instance of Trunk </returns>
        public static bool Delete(string pathSid, ITwilioRestClient client = null)
        {
            var options = new DeleteTrunkOptions(pathSid);

            return(Delete(options, client));
        }
예제 #4
0
        /// <summary>
        /// create
        /// </summary>
        /// <param name="pathMessageSid"> The SID of the Message resource for which the feedback was provided </param>
        /// <param name="pathAccountSid"> The SID of the Account that will create the resource </param>
        /// <param name="outcome"> Whether the feedback has arrived </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of Feedback </returns>
        public static async System.Threading.Tasks.Task <FeedbackResource> 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));
        }
예제 #5
0
        /// <summary>
        /// Returns a list of events in the account, sorted by event-date.
        /// </summary>
        /// <param name="actorSid"> Only include events initiated by this Actor </param>
        /// <param name="eventType"> Only include events of this Event Type </param>
        /// <param name="resourceSid"> Only include events that refer to this resource </param>
        /// <param name="sourceIpAddress"> Only include events that originated from this IP address </param>
        /// <param name="startDate"> Only include events that occurred on or after this date </param>
        /// <param name="endDate"> Only include events that occurred on or before this date </param>
        /// <param name="pageSize"> Page size </param>
        /// <param name="limit"> Record limit </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of Event </returns>
        public static async System.Threading.Tasks.Task <ResourceSet <EventResource> > 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));
        }
예제 #6
0
        /// <summary>
        /// fetch
        /// </summary>
        ///
        /// <param name="pathServiceSid"> The service_sid </param>
        /// <param name="pathChannelSid"> The channel_sid </param>
        /// <param name="pathSid"> The sid </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> A single instance of Invite </returns>
        public static InviteResource Fetch(string pathServiceSid, string pathChannelSid, string pathSid, ITwilioRestClient client = null)
        {
            var options = new FetchInviteOptions(pathServiceSid, pathChannelSid, pathSid);

            return(Fetch(options, client));
        }
예제 #7
0
        /// <summary>
        /// delete
        /// </summary>
        ///
        /// <param name="pathServiceSid"> The service_sid </param>
        /// <param name="pathChannelSid"> The channel_sid </param>
        /// <param name="pathSid"> The sid </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of Invite </returns>
        public static async System.Threading.Tasks.Task <bool> DeleteAsync(string pathServiceSid, string pathChannelSid, string pathSid, ITwilioRestClient client = null)
        {
            var options = new DeleteInviteOptions(pathServiceSid, pathChannelSid, pathSid);

            return(await DeleteAsync(options, client));
        }
예제 #8
0
        /// <summary>
        /// delete
        /// </summary>
        ///
        /// <param name="options"> Delete Invite parameters </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of Invite </returns>
        public static async System.Threading.Tasks.Task <bool> 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);
        }
예제 #9
0
        /// <summary>
        /// Fetch the previous page of records
        /// </summary>
        /// <param name="page"> current page of records </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> The previous page of records </returns>
        public static Page <MonthlyResource> PreviousPage(Page <MonthlyResource> page, ITwilioRestClient client)
        {
            var request = new Request(
                HttpMethod.Get,
                page.GetPreviousPageUrl(
                    Rest.Domain.Api,
                    client.Region
                    )
                );

            var response = client.Request(request);

            return(Page <MonthlyResource> .FromJson("usage_records", response.Content));
        }
예제 #10
0
        /// <summary>
        /// read
        /// </summary>
        /// <param name="pathAccountSid"> The account_sid </param>
        /// <param name="category"> The category </param>
        /// <param name="startDate"> The start_date </param>
        /// <param name="endDate"> The end_date </param>
        /// <param name="pageSize"> Page size </param>
        /// <param name="limit"> Record limit </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of Monthly </returns>
        public static async System.Threading.Tasks.Task <ResourceSet <MonthlyResource> > ReadAsync(string pathAccountSid = null,
                                                                                                   MonthlyResource.CategoryEnum category = null,
                                                                                                   DateTime?startDate       = null,
                                                                                                   DateTime?endDate         = null,
                                                                                                   int?pageSize             = null,
                                                                                                   long?limit               = null,
                                                                                                   ITwilioRestClient client = null)
        {
            var options = new ReadMonthlyOptions()
            {
                PathAccountSid = pathAccountSid, Category = category, StartDate = startDate, EndDate = endDate, PageSize = pageSize, Limit = limit
            };

            return(await ReadAsync(options, client));
        }
예제 #11
0
        /// <summary>
        /// Fetch an instance of a connect-app
        /// </summary>
        ///
        /// <param name="pathSid"> Fetch by unique connect-app Sid </param>
        /// <param name="pathAccountSid"> The account_sid </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> A single instance of ConnectApp </returns>
        public static ConnectAppResource Fetch(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null)
        {
            var options = new FetchConnectAppOptions(pathSid)
            {
                PathAccountSid = pathAccountSid
            };

            return(Fetch(options, client));
        }
예제 #12
0
        /// <summary>
        /// Fetch the next page of records
        /// </summary>
        ///
        /// <param name="page"> current page of records </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> The next page of records </returns>
        public static Page <ConnectAppResource> NextPage(Page <ConnectAppResource> page, ITwilioRestClient client)
        {
            var request = new Request(
                HttpMethod.Get,
                page.GetNextPageUrl(
                    Rest.Domain.Api,
                    client.Region
                    )
                );

            var response = client.Request(request);

            return(Page <ConnectAppResource> .FromJson("connect_apps", response.Content));
        }
예제 #13
0
        /// <summary>
        /// Retrieve a list of connect-apps belonging to the account used to make the request
        /// </summary>
        ///
        /// <param name="pathAccountSid"> The account_sid </param>
        /// <param name="pageSize"> Page size </param>
        /// <param name="limit"> Record limit </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> A single instance of ConnectApp </returns>
        public static ResourceSet <ConnectAppResource> 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));
        }
예제 #14
0
        /// <summary>
        /// Retrieve a list of connect-apps belonging to the account used to make the request
        /// </summary>
        ///
        /// <param name="options"> Read ConnectApp parameters </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> A single instance of ConnectApp </returns>
        public static ResourceSet <ConnectAppResource> Read(ReadConnectAppOptions options, ITwilioRestClient client = null)
        {
            client = client ?? TwilioClient.GetRestClient();
            var response = client.Request(BuildReadRequest(options, client));

            var page = Page <ConnectAppResource> .FromJson("connect_apps", response.Content);

            return(new ResourceSet <ConnectAppResource>(page, options, client));
        }
예제 #15
0
        /// <summary>
        /// Update a connect-app with the specified parameters
        /// </summary>
        ///
        /// <param name="pathSid"> The sid </param>
        /// <param name="pathAccountSid"> The account_sid </param>
        /// <param name="authorizeRedirectUrl"> URIL Twilio sends requests when users authorize </param>
        /// <param name="companyName"> The company name set for this Connect App. </param>
        /// <param name="deauthorizeCallbackMethod"> HTTP method Twilio WIll use making requests to the url </param>
        /// <param name="deauthorizeCallbackUrl"> URL Twilio will send a request when a user de-authorizes this app </param>
        /// <param name="description"> A more detailed human readable description </param>
        /// <param name="friendlyName"> A human readable name for the Connect App. </param>
        /// <param name="homepageUrl"> The URL users can obtain more information </param>
        /// <param name="permissions"> The set of permissions that your ConnectApp requests. </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of ConnectApp </returns>
        public static async System.Threading.Tasks.Task <ConnectAppResource> 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 <ConnectAppResource.PermissionEnum> 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));
        }
예제 #16
0
        /// <summary>
        /// read
        /// </summary>
        ///
        /// <param name="pathServiceSid"> The service_sid </param>
        /// <param name="pathChannelSid"> The channel_sid </param>
        /// <param name="identity"> The identity </param>
        /// <param name="pageSize"> Page size </param>
        /// <param name="limit"> Record limit </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of Invite </returns>
        public static async System.Threading.Tasks.Task <ResourceSet <InviteResource> > ReadAsync(string pathServiceSid, string pathChannelSid, List <string> 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));
        }
예제 #17
0
        /// <summary>
        /// Retrieve the members of the queue
        /// </summary>
        /// <param name="pathQueueSid"> The SID of the Queue in which to find the members </param>
        /// <param name="pathAccountSid"> The SID of the Account that created the resource(s) to read </param>
        /// <param name="pageSize"> Page size </param>
        /// <param name="limit"> Record limit </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of Member </returns>
        public static async System.Threading.Tasks.Task <ResourceSet <MemberResource> > 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));
        }
예제 #18
0
        /// <summary>
        /// delete
        /// </summary>
        ///
        /// <param name="pathServiceSid"> The service_sid </param>
        /// <param name="pathChannelSid"> The channel_sid </param>
        /// <param name="pathSid"> The sid </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> A single instance of Invite </returns>
        public static bool Delete(string pathServiceSid, string pathChannelSid, string pathSid, ITwilioRestClient client = null)
        {
            var options = new DeleteInviteOptions(pathServiceSid, pathChannelSid, pathSid);

            return(Delete(options, client));
        }
        /// <summary>
        /// Create a new Verification for a To number using a Service
        /// </summary>
        /// <param name="pathServiceSid"> The SID of the verification Service to create the resource under </param>
        /// <param name="to"> The phone number to verify </param>
        /// <param name="channel"> The verification method to use </param>
        /// <param name="customMessage"> The text of a custom message to use for the verification </param>
        /// <param name="sendDigits"> The digits to send after a phone call is answered </param>
        /// <param name="locale"> The locale to use for the verification SMS or call </param>
        /// <param name="customCode"> A pre-generated code </param>
        /// <param name="amount"> The amount of the associated PSD2 compliant transaction. </param>
        /// <param name="payee"> The payee of the associated PSD2 compliant transaction </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of Verification </returns>
        public static async System.Threading.Tasks.Task <VerificationResource> CreateAsync(string pathServiceSid,
                                                                                           string to,
                                                                                           string channel,
                                                                                           string customMessage     = null,
                                                                                           string sendDigits        = null,
                                                                                           string locale            = null,
                                                                                           string customCode        = null,
                                                                                           string amount            = null,
                                                                                           string payee             = null,
                                                                                           ITwilioRestClient client = null)
        {
            var options = new CreateVerificationOptions(pathServiceSid, to, channel)
            {
                CustomMessage = customMessage, SendDigits = sendDigits, Locale = locale, CustomCode = customCode, Amount = amount, Payee = payee
            };

            return(await CreateAsync(options, client));
        }
예제 #20
0
        /// <summary>
        /// fetch
        /// </summary>
        ///
        /// <param name="options"> Fetch Invite parameters </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of Invite </returns>
        public static async System.Threading.Tasks.Task <InviteResource> FetchAsync(FetchInviteOptions options, ITwilioRestClient client = null)
        {
            client = client ?? TwilioClient.GetRestClient();
            var response = await client.RequestAsync(BuildFetchRequest(options, client));

            return(FromJson(response.Content));
        }
        /// <summary>
        /// Update a Verification status
        /// </summary>
        /// <param name="options"> Update Verification parameters </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of Verification </returns>
        public static async System.Threading.Tasks.Task <VerificationResource> UpdateAsync(UpdateVerificationOptions options,
                                                                                           ITwilioRestClient client = null)
        {
            client = client ?? TwilioClient.GetRestClient();
            var response = await client.RequestAsync(BuildUpdateRequest(options, client));

            return(FromJson(response.Content));
        }
예제 #22
0
        /// <summary>
        /// fetch
        /// </summary>
        ///
        /// <param name="pathServiceSid"> The service_sid </param>
        /// <param name="pathChannelSid"> The channel_sid </param>
        /// <param name="pathSid"> The sid </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of Invite </returns>
        public static async System.Threading.Tasks.Task <InviteResource> FetchAsync(string pathServiceSid, string pathChannelSid, string pathSid, ITwilioRestClient client = null)
        {
            var options = new FetchInviteOptions(pathServiceSid, pathChannelSid, pathSid);

            return(await FetchAsync(options, client));
        }
        /// <summary>
        /// Update a Verification status
        /// </summary>
        /// <param name="pathServiceSid"> The SID of the verification Service to update the resource from </param>
        /// <param name="pathSid"> The unique string that identifies the resource </param>
        /// <param name="status"> The new status of the resource </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of Verification </returns>
        public static async System.Threading.Tasks.Task <VerificationResource> UpdateAsync(string pathServiceSid,
                                                                                           string pathSid,
                                                                                           VerificationResource.StatusEnum status,
                                                                                           ITwilioRestClient client = null)
        {
            var options = new UpdateVerificationOptions(pathServiceSid, pathSid, status);

            return(await UpdateAsync(options, client));
        }
예제 #24
0
        /// <summary>
        /// fetch
        /// </summary>
        /// <param name="pathSid"> The SID that identifies the resource to fetch </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> A single instance of Event </returns>
        public static EventResource Fetch(string pathSid, ITwilioRestClient client = null)
        {
            var options = new FetchEventOptions(pathSid);

            return(Fetch(options, client));
        }
        /// <summary>
        /// Fetch a specific Verification
        /// </summary>
        /// <param name="pathServiceSid"> The SID of the verification Service to fetch the resource from </param>
        /// <param name="pathSid"> The unique string that identifies the resource </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> A single instance of Verification </returns>
        public static VerificationResource Fetch(string pathServiceSid, string pathSid, ITwilioRestClient client = null)
        {
            var options = new FetchVerificationOptions(pathServiceSid, pathSid);

            return(Fetch(options, client));
        }
예제 #26
0
        /// <summary>
        /// create
        /// </summary>
        /// <param name="options"> Create Feedback parameters </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of Feedback </returns>
        public static async System.Threading.Tasks.Task <FeedbackResource> CreateAsync(CreateFeedbackOptions options,
                                                                                       ITwilioRestClient client = null)
        {
            client = client ?? TwilioClient.GetRestClient();
            var response = await client.RequestAsync(BuildCreateRequest(options, client));

            return(FromJson(response.Content));
        }
예제 #27
0
        /// <summary>
        /// create
        /// </summary>
        ///
        /// <param name="pathServiceSid"> The service_sid </param>
        /// <param name="pathChannelSid"> The channel_sid </param>
        /// <param name="identity"> The identity </param>
        /// <param name="roleSid"> The role_sid </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> A single instance of Invite </returns>
        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));
        }
예제 #28
0
        /// <summary>
        /// delete
        /// </summary>
        /// <param name="pathSid"> The sid </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of Trunk </returns>
        public static async System.Threading.Tasks.Task <bool> DeleteAsync(string pathSid, ITwilioRestClient client = null)
        {
            var options = new DeleteTrunkOptions(pathSid);

            return(await DeleteAsync(options, client));
        }
예제 #29
0
        /// <summary>
        /// create
        /// </summary>
        ///
        /// <param name="pathServiceSid"> The service_sid </param>
        /// <param name="pathChannelSid"> The channel_sid </param>
        /// <param name="identity"> The identity </param>
        /// <param name="roleSid"> The role_sid </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of Invite </returns>
        public static async System.Threading.Tasks.Task <InviteResource> 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));
        }
예제 #30
0
        /// <summary>
        /// read
        /// </summary>
        ///
        /// <param name="pathServiceSid"> The service_sid </param>
        /// <param name="pathChannelSid"> The channel_sid </param>
        /// <param name="identity"> The identity </param>
        /// <param name="pageSize"> Page size </param>
        /// <param name="limit"> Record limit </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> A single instance of Invite </returns>
        public static ResourceSet <InviteResource> Read(string pathServiceSid, string pathChannelSid, List <string> 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));
        }
예제 #31
0
        /// <summary>
        /// Fetch an instance of a connect-app
        /// </summary>
        ///
        /// <param name="pathSid"> Fetch by unique connect-app Sid </param>
        /// <param name="pathAccountSid"> The account_sid </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of ConnectApp </returns>
        public static async System.Threading.Tasks.Task <ConnectAppResource> FetchAsync(string pathSid, string pathAccountSid = null, ITwilioRestClient client = null)
        {
            var options = new FetchConnectAppOptions(pathSid)
            {
                PathAccountSid = pathAccountSid
            };

            return(await FetchAsync(options, client));
        }