private static void UpdateSupportTicketContact(string supportTicketName, UpdateContactProfile contact)
 {
     UpdateSupportTicket(supportTicketName, new UpdateSupportTicket()
     {
         ContactDetails = contact
     });
 }
Пример #2
0
        public override void ExecuteCmdlet()
        {
            try
            {
                if (this.IsParameterBound(c => c.InputObject))
                {
                    this.Name = this.InputObject.Name;
                }

                SupportTicketDetails supportTicket = null;

                supportTicket = this.SupportClient.SupportTickets.Get(this.Name);

                var updateSupportTicket = new UpdateSupportTicket();

                if (this.IsParameterBound(c => c.Severity))
                {
                    updateSupportTicket.Severity = this.Severity.ToString();
                }

                UpdateContactProfile updateContactProfile = null;
                if (this.ParameterSetName.Equals(UpdateByNameWithContactObjectParameterSet) ||
                    this.ParameterSetName.Equals(UpdateByInputObjectWithContactObjectParameterSet))
                {
                    updateContactProfile = this.CustomerContactDetail.ToSdkContactProfile();
                }
                else
                {
                    updateContactProfile = new UpdateContactProfile
                    {
                        FirstName                = this.IsParameterBound(c => c.CustomerFirstName) ? this.CustomerFirstName : null,
                        LastName                 = this.IsParameterBound(c => c.CustomerLastName) ? this.CustomerLastName : null,
                        PrimaryEmailAddress      = this.IsParameterBound(c => c.CustomerPrimaryEmailAddress) ? this.CustomerPrimaryEmailAddress : null,
                        PreferredTimeZone        = this.IsParameterBound(c => c.CustomerPreferredTimeZone) ? this.CustomerPreferredTimeZone : null,
                        PreferredSupportLanguage = this.IsParameterBound(c => c.CustomerPreferredSupportLanguage) ? this.CustomerPreferredSupportLanguage : null,
                        PhoneNumber              = this.IsParameterBound(c => c.CustomerPhoneNumber) ? this.CustomerPhoneNumber : null,
                        AdditionalEmailAddresses = this.IsParameterBound(c => c.AdditionalEmailAddress) ? this.AdditionalEmailAddress.ToList() : null,
                        Country = this.IsParameterBound(c => c.CustomerCountry) ? this.CustomerCountry : null,
                        PreferredContactMethod = this.IsParameterBound(c => c.PreferredContactMethod) ? this.PreferredContactMethod.ToString() : null
                    };
                }

                updateSupportTicket.ContactDetails = updateContactProfile;

                if (this.ShouldProcess(this.Name, string.Format("Updating SupportTicket '{0}'.", this.Name)))
                {
                    var result = this.SupportClient.SupportTickets.Update(this.Name, updateSupportTicket);
                    this.WriteObject(result.ToPSSupportTicket());
                }
            }
            catch (ExceptionResponseException ex)
            {
                throw new PSArgumentException(string.Format("Error response received. Error Message: '{0}'",
                                                            ex.Response.Content));
            }
        }