To work with the library, you must be authorized on your data, for this you can use the provided AmoCrmConfig class, and then you do not have to transfer authorization data with each request or cookie containers, also this class already contains the necessary api access addresses. You can not use this class, since there are overridable methods to which you can pass your data for authorization, in the form of a container of cookies, or an instance of NetworkCredential, as well as your url address for calls.
1. Getting account information: "Task <T> GetAccountInfoAsync <T> ()"
2. Work with contacts in the service, includes methods:
2.1. Receiving:
1. Getting a contact by its ID - "Task <T> GetContactByIdAsync <T> (long contactId)"
2. Getting a list of all contacts - "Task <T> GetContactsAsync <T> ()"
3. Getting contact by query string (query) - "Task <T> GetContactByQueryAsync <T> (string query)"
4. Getting the contact by the responsible user ID - "Task <T> GetContactByResponsibleUserIdAsync <T> (long responsibleUserId)"
2.2. Add or update:
1. Adding or updating a contact by passing the contact structure to the method - "Task <T> AddOrUpdateContactAsync <T> (AddOrUpdateCommand <AmoCrmContact> contacts)"
3. Work with transactions in the service includes methods:
3.1. Receiving:
1. Getting all trades - "Task <T> GetLeadsAsync <T> ()"
3.2. Addendum:
1. Adding a deal by passing the deal structure to the method - "Task <T> AddLeadAsync <T> (AddOrUpdateCommand <AmoCrmLead> leads)"
4. Work with companies in the service includes methods:
4.1. Receiving:
1. Getting a company by its ID - "Task <T> GetCompanyByIdAsync <T> (long companyId)"
2. Getting the company by query line (query) - "Task <T> GetCompanyByQueryAsync <T> (string query)"
3. Getting the company by the responsible user ID - "Task <T> GetCompanyByResponsibleUserIdAsync <T> (long responsibleUserId)"
4.2. Addendum:
1. Adding or updating a company by passing the company structure to the method - "Task <T> AddCompanyAsync <T> (AddOrUpdateCommand <AmoCrmCompany> company)"
5. Universal methods for obtaining or adding something according to the structure of the transferred class, having several overloads in terms of the transmitted parameters:
5.1. Options:
1. "Task <T> AddObjAsync <T> (AddOrUpdateCommand <T> obj, string url)", add or update, where T is the structure to be transmitted or updated, url is the api address in the service to which the request will go
5.2. Overloads may contain the following fields:
1. CookieContainer cookies - cookie container for authorization
2. NetworkCredential credential - container for authorization (Fields: UserName, Password, Domain)
3. "Task <T> GetObjByIdAsync <T> (string id, string url)", receiving, where T is the structure to be transmitted or updated, ID is the id of the received object, url is the api address in the service the request will be sent to
- The query string (query) - Task GetObjByQueryAsync (string query, string url)
- Id of the responsible user (responsibleUserId) - Task GetObjByResponsibleUserIdAsync (long responsibleUserId, string url)
- Obtaining a list without parameters - Task GetObjListAsync (string url)
- CookieContainer cookies - cookie container for authorization
- NetworkCredential credential - container for authorization (Fields: UserName, Password, Domain)
- int? limitRows - limit for receiving fields (by default - 500)
- int? limitOffSet - shift of the received fields (used for transmission - limitRows, default - 0)
- DateTime? modifiedSince - time and date of modification (default is null)
- "Task GetObjListAsync (string url, NetworkCredential credential, int? LimitRows = 500, int? limitOffSet = 0, DateTime? modifiedSince = null) "
- "Task GetObjListAsync (string url, CookieContainer cookies, int? LimitRows = 500, int? limitOffSet = 0, DateTime? modifiedSince = null) "
- Contacts - "AmoCrmContact" - Includes a complete contact structure
- Account - "CrmAccountInfo" - Includes all account fields
- Transactions - "AmoCrmLead" - Includes all transaction fields
- Companies - "AmoCrmCompany" - Includes all fields of the company
To send a request for addition or update to the selected method, you must use the ready-made structure: - "AddOrUpdateCommand", the data structure for the request is passed to it
public class ExampleClass1 { private AmoCrmService _service;
private static readonly string _userHash = "123123123123123sdf123daf123sdgf123"; private static readonly string _userLogin = "Test@mail.ru"; private static readonly string _subDomen = "test";
public ExampleClass1 () { var crmConfig = new AmoCrmConfig (_subDomen, _userLogin, _userHash); _service = new AmoCrmService (crmConfig); } }
public Task AddContact (AmoCrmContact contact) { var response = _service.AddOrUpdateContactAsync (new AddOrUpdateCommand { ItemAdd = new List { contact } }); return response; }
public Task AddContact (AmoCrmContact contact) { var response = _service.AddOrUpdateContactAsync (new AddOrUpdateCommand { ItemUpdate = new List { contact } }); return response; }
public Task GetContact (long id) { var response = _service.GetContactByIdAsync (id); return response; }
public Task GetAccountInfo () { var response = _service.GetAccountInfoAsync (); return response; }