示例#1
0
        /// <summary>
        /// Removes contacts from one ore more contact lists.
        /// </summary>
        /// <param name="accessToken">Constant Contact OAuth2 access token.</param>
        /// <param name="apiKey">The API key for the application</param>
        /// <param name="emailAddresses">List of email addresses.</param>
        /// <param name="lists">List of id's.</param>
        /// <returns>Returns an Activity object.</returns>
        public Activity RemoveContactsFromLists(string accessToken, string apiKey, IList <string> emailAddresses, IList <string> lists)
        {
            Activity      activity      = null;
            string        url           = String.Concat(Config.Endpoints.BaseUrl, Config.Endpoints.RemoveFromListsActivity);
            RemoveContact removeContact = new RemoveContact()
            {
                ImportData = new List <ImportEmailAddress>()
                {
                    new ImportEmailAddress()
                    {
                        EmailAddresses = emailAddresses
                    }
                },
                Lists = lists
            };

            string       json     = removeContact.ToJSON();
            CUrlResponse response = RestClient.Post(url, accessToken, apiKey, json);

            if (response.IsError)
            {
                throw new CtctException(response.GetErrorMessage());
            }

            if (response.HasData)
            {
                activity = response.Get <Activity>();
            }

            return(activity);
        }
 public override void CommitEditingStyle(
     UITableView tableView,
     UITableViewCellEditingStyle editingStyle,
     NSIndexPath indexPath)
 {
     RemoveContact?.Invoke(this, indexPath.Row);
 }
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            var contact = _contacts[position];

            var contactHolder = holder as ContactViewHolder;

            contactHolder.Name.Text  = contact.Name;
            contactHolder.Phone.Text = contact.Phone;

            var resId = (int)typeof(Resource.Drawable)
                        .GetField(contact.ProfileIcon)
                        .GetValue(null);

            contactHolder.ProfileIconImageView.SetImageResource(resId);
            contactHolder.RemoveContact.Click += delegate { RemoveContact?.Invoke(this, position); };
        }
示例#4
0
        /// <summary>
        /// Create a Remove Contacts From Lists Activity.
        /// </summary>
        /// <param name="emailAddresses">List of email addresses.</param>
        /// <param name="lists">List of id's.</param>
        /// <returns>Returns an Activity object.</returns>
        public Activity AddRemoveContactsFromListsActivity(IList <string> emailAddresses, IList <string> lists)
        {
            if (emailAddresses == null || lists == null)
            {
                throw new IllegalArgumentException(CTCT.Resources.Errors.ActivityOrId);
            }

            string url = String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.RemoveFromListsActivity);

            IList <ImportEmailAddress> emails = new List <ImportEmailAddress>();

            foreach (string email in emailAddresses)
            {
                emails.Add(new ImportEmailAddress()
                {
                    EmailAddresses = new List <String>()
                    {
                        email
                    }
                });
            }

            RemoveContact removeContact = new RemoveContact()
            {
                ImportData = emails,
                Lists      = lists
            };

            string         json     = removeContact.ToJSON();
            RawApiResponse response = RestClient.Post(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey, json);

            try
            {
                var activity = response.Get <Activity>();
                return(activity);
            }
            catch (Exception ex)
            {
                throw new CtctException(ex.Message, ex);
            }
        }