예제 #1
0
        public List <AddedOrUpdatedNote> AddOrUpdateNote(AddOrUpdateNoteRequest addOrUpdateNoteRequest)
        {
            var request  = addOrUpdateNoteRequest;
            var response = AmoMethod.Post <AddOrUpdateNoteResponse>(request, _crmConfig);

            return(response.Response.Tasks);
        }
예제 #2
0
        public List <AddedOrUpdatedContact> AddOrUpdateContact(AddOrUpdateContactRequest addOrUpdateContactRequest)
        {
            var request  = addOrUpdateContactRequest;
            var response = AmoMethod.Post <AddOrUpdateContactResponse>(request, _crmConfig);

            return(response.Response.Contacts);
        }
예제 #3
0
        public List <AddedOrUpdatedLead> AddOrUpdateLead(AddOrUpdateLeadRequest addOrUpdateLeadRequest)
        {
            var request  = addOrUpdateLeadRequest;
            var response = AmoMethod.Post <AddOrUpdateLeadResponse>(request, _crmConfig);

            long id = 0;

            if (addOrUpdateLeadRequest.Request.Leads.Add != null)
            {
                id = response.Response.Leads.Add.First().Id;
            }
            else
            {
                id = response.Response.Leads.Update.First().Id;
            }
            return(new List <AddedOrUpdatedLead>()
            {
                new AddedOrUpdatedLead()
                {
                    Id = id
                }
            });

            //return response.Response.Leads;
        }
예제 #4
0
        public IEnumerable <CrmCompany> GetCompanies()
        {
            var companies = new List <CrmCompany>();

            for (var offset = 0; ; offset += _crmConfig.LimitRows ?? 500)
            {
                _crmConfig.LimitOffset = offset;
                var companiesList = AmoMethod.Get <CrmGetCompanyResponse>(_crmConfig);
                if (companiesList == null)
                {
                    break;
                }
                if (companiesList.Response.Error == "Неверный логин или пароль")
                {
                    Thread.Sleep(5000);
                    companiesList = AmoMethod.Get <CrmGetCompanyResponse>(_crmConfig);
                    if (companiesList == null)
                    {
                        break;
                    }
                }
                companies.AddRange(companiesList.Response.Companies);
                if (offset > 0 && offset % 500 == 0)
                {
                    Thread.Sleep(1000);
                }

                //if (offset > 300)   break;
            }
            return(companies);
        }
예제 #5
0
        public List <AddedOrUpdatedCompany> AddOrUpdateCompany(AddOrUpdateCompanyRequest addOrUpdateCompanyRequest)
        {
            var request  = addOrUpdateCompanyRequest;
            var response = AmoMethod.Post <AddOrUpdateCompanyResponse>(request, _crmConfig);

            return(response.Response.Companies);
        }
예제 #6
0
        public CrmContact GetContact(long contactId)
        {
            var parameterId = new Parameter {
                Name = "id", Value = contactId, Type = ParameterType.QueryString
            };
            var contact = AmoMethod.Get <CrmGetContactResponse>(_crmConfig, parameterId);

            return(contact?.Response?.Contacts?.FirstOrDefault());
        }
예제 #7
0
        public CrmCompany GetCompany(long companyId)
        {
            var parameterId = new Parameter {
                Name = "id", Value = companyId, Type = ParameterType.QueryString
            };
            var company = AmoMethod.Get <CrmGetCompanyResponse>(_crmConfig, parameterId);

            return(company.Response.Companies.FirstOrDefault());
        }
예제 #8
0
        public CrmAccountInfo GetAccountInfo()
        {
            var accountInfo = AmoMethod.Get <CrmGetAccountInfoResponse>(_crmConfig);

            if (accountInfo == null || accountInfo.Response == null)
            {
                throw new AmoCrmException(AmoCrmErrors.Unknown);
            }
            return(accountInfo.Response.Account);
        }
예제 #9
0
        public CrmLead GetLead(long leadId)
        {
            var parameterId = new Parameter {
                Name = "id", Value = leadId, Type = ParameterType.QueryString
            };
            var leadsList = AmoMethod.Get <CrmGetLeadResponse>(_crmConfig, parameterId);

            if (leadsList == null)
            {
                return(null);
            }
            return(leadsList.Response.Leads.FirstOrDefault());
        }
예제 #10
0
        public IEnumerable <CrmPipeline> GetPipelines()
        {
            var pipelines = new List <CrmPipeline>();

            for (var offset = 0; ; offset += _crmConfig.LimitRows ?? 500)
            {
                _crmConfig.LimitOffset = offset;
                var pipelinesList = AmoMethod.Get <CrmGetPipeLineResponse>(_crmConfig);

                pipelines.AddRange(pipelinesList.Response.Pipelines.Select(t => t.Value).ToList());
                break;
            }
            return(pipelines);
        }
예제 #11
0
        public IEnumerable <CrmContact> GetContacts()
        {
            var contacts = new List <CrmContact>();

            for (var offset = 0;; offset += _crmConfig.LimitRows ?? 500)
            {
                _crmConfig.LimitOffset = offset;
                var contactsList = AmoMethod.Get <CrmGetContactResponse>(_crmConfig);
                if (contactsList == null)
                {
                    break;
                }
                contacts.AddRange(contactsList.Response.Contacts);
            }
            return(contacts);
        }
예제 #12
0
        public IEnumerable <CrmLead> GetLeads()
        {
            var leads = new List <CrmLead>();

            for (var offset = 0; ; offset += _crmConfig.LimitRows ?? 500)
            {
                _crmConfig.LimitOffset = offset;
                var leadsList = AmoMethod.Get <CrmGetLeadResponse>(_crmConfig);
                if (leadsList == null)
                {
                    break;
                }
                leads.AddRange(leadsList.Response.Leads);
            }
            return(leads);
        }
예제 #13
0
        public IEnumerable <CrmContact> GetContacts(long responsibleUserId)
        {
            var contacts = new List <CrmContact>();

            for (var offset = 0;; offset += _crmConfig.LimitRows ?? 500)
            {
                _crmConfig.LimitOffset = offset;
                var parameterResponsibleUserId = new Parameter {
                    Name = "responsible_user_id", Value = responsibleUserId, Type = ParameterType.QueryString
                };
                var contactsList = AmoMethod.Get <CrmGetContactResponse>(_crmConfig, parameterResponsibleUserId);
                if (contactsList == null)
                {
                    break;
                }
                contacts.AddRange(contactsList.Response.Contacts);
            }
            return(contacts);
        }
예제 #14
0
        public IEnumerable <CrmNote> GetNotes(string query)
        {
            var notes = new List <CrmNote>();

            for (var offset = 0; ; offset += _crmConfig.LimitRows ?? 500)
            {
                _crmConfig.LimitOffset = offset;
                var parameterResponsibleUserId = new Parameter {
                    Name = "query", Value = query, Type = ParameterType.QueryString
                };
                var contactsList = AmoMethod.Get <CrmGetNoteResponse>(_crmConfig, parameterResponsibleUserId);
                if (contactsList == null)
                {
                    break;
                }
                notes.AddRange(contactsList.Response.Notes);
            }
            return(notes);
        }
예제 #15
0
        public IEnumerable <CrmLead> GetLeads(int status)
        {
            var leads = new List <CrmLead>();

            for (var offset = 0; ; offset += _crmConfig.LimitRows ?? 500)
            {
                _crmConfig.LimitOffset = offset;
                var parameterQuery = new Parameter {
                    Name = "status", Value = status.ToString(), Type = ParameterType.QueryString
                };
                var leadsList = AmoMethod.Get <CrmGetLeadResponse>(_crmConfig, parameterQuery);
                if (leadsList == null)
                {
                    break;
                }
                leads.AddRange(leadsList.Response.Leads);
            }
            return(leads);
        }
예제 #16
0
        public IEnumerable <CrmContact> GetContacts(string query)
        {
            var contacts = new List <CrmContact>();

            for (var offset = 0;; offset += _crmConfig.LimitRows ?? 500)
            {
                _crmConfig.LimitOffset = offset;
                var parameterQuery = new Parameter {
                    Name = "query", Value = query, Type = ParameterType.QueryString
                };
                var contactsList = AmoMethod.Get <CrmContactResponse>(_crmConfig, parameterQuery);
                if (contactsList == null)
                {
                    break;
                }
                contacts.AddRange(contactsList.Response.Contacts);
            }
            return(contacts);
        }
예제 #17
0
        public IEnumerable <CrmCompany> GetCompanies(string query)
        {
            var companies = new List <CrmCompany>();

            for (var offset = 0; ; offset += _crmConfig.LimitRows ?? 500)
            {
                _crmConfig.LimitOffset = offset;
                var parameterQuery = new Parameter {
                    Name = "query", Value = query, Type = ParameterType.QueryString
                };
                var companiesList = AmoMethod.Get <CrmGetCompanyResponse>(_crmConfig, parameterQuery);
                if (companiesList == null)
                {
                    break;
                }
                companies.AddRange(companiesList.Response.Companies);
                if (offset > 0 && offset % 1000 == 0)
                {
                    Thread.Sleep(1000);
                }
            }
            return(companies);
        }