---
title: "Using lacrmr"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Using lacrmr}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

```{r setup}
library(lacrmr)
```

# Why using lacrmr?

lacrmr is a package that allows you to connect with your [Less Annoying CRM](https://www.lessannoyingcrm.com/) account and obtain the data of your customers and contacts.

## Using lacrmr:

The first step is to look for the credentials in order to connect to your lacrm. When you are logged into your account, go to `settings` \> `Programmer API`

Here you will need to create an API Token. When you go through this process you will obtain two pieces of information:

-   **User code**
-   **API token**

Please make sure to save this credentials in a secure place. Otherwise anyone with this credential will be able to check your information through an API.

Then if you go down on the page, you will see other pieces of information as **User ID'S**, **Pipeline ID** and **Status ID**. This info will be useful in order to make use of the functions in this package.

# What information can we obtain with lacrmr?

The lacrmr package have four functions:

-   `get_pipeline_report()`
-   `search_contacts()`
-   `get_contact_information()`
-   `get_account_information()`

## **`get_pipeline_report()`**

This function returns the data from one specific pipeline that you create on your CRM. For this you will need to obtain the pipeline id that you want to work with from R.

The variables to obtain with this function are:

```         
 [1] "result_contact_id"                           
 [2] "result_user_id"                              
 [3] "result_company_id"                           
 [4] "result_background_info"                      
 [5] "result_birthday"                             
 [6] "result_is_company"                           
 [7] "result_company_name"                         
 [8] "result_industry"                             
 [9] "result_num_employees"                        
[10] "result_creation_date"                        
[11] "result_edited_date"                          
[12] "result_original_google_id"                   
[13] "result_employer_name"                        
[14] "result_company_employees"                    
[15] "result_pipeline_id"                          
[16] "result_status_id"                            
[17] "result_priority"                             
[18] "result_last_note"                            
[19] "result_start_date"                           
[20] "result_last_update"                          
[21] "result_num_updates"                          
[22] "result_start_status_id"                      
[23] "result_last_updated_by"                      
[24] "result_sort_order"                           
[25] "result_show_in_reports"                      
[26] "result_pipeline_item_id"                     
[27] "result_status_name"                          
[28] "success"                                     
[29] "result_custom_fields_priority"               
[30] "result_custom_fields_descripcion_oportunidad"
[31] "result_custom_fields_valor"
```

## **`search_contacts()`**

This function will make you sure about if a contact id exists or not on your CRM records.

If the contact id you provided to the function does indeed exists, you will see the message `The search item does exists in the CRM`. If not, the message will be `There is no such item in the CRM`

## **`get_contact_information()`**

This function will allow you to return the contact information storage in your CRM. When you use this function with a specific contact id, you will see the next variables:

```         
 [1] "contact_contact_id"            "contact_user_id"              
 [3] "contact_company_id"            "contact_email"                
 [5] "contact_phone"                 "contact_text"                 
 [7] "contact_address_street"        "contact_address_city"         
 [9] "contact_address_state"         "contact_address_country"      
[11] "contact_address_zip"           "contact_address_type"         
[13] "contact_address_type_id"       "contact_background_info"      
[15] "contact_birthday"              "contact_is_company"           
[17] "contact_company_name"          "contact_industry"             
[19] "contact_num_employees"         "contact_creation_date"        
[21] "contact_edited_date"           "contact_original_google_id"   
[23] "contact_custom_fields"         "contact_contact_custom_fields"
```

## **`get_account_information()`**

This function will simply show the information of your account or the account from which you entered the credentials to obtain the access to lacrm. The variables will be:

```         
 [1] "FirstName"          "LastName"           "Email"             
 [4] "UserId"             "AccountId"          "IsOwner"           
 [7] "IsAdmin"            "BlockExports"       "Timezone"          
[10] "DateUserCreated"    "DateAccountCreated" "Success" 
```

# Obtaining credentials:

In order to make the package works, you would need to create an .Renviron file inside your working directory that should contain environment variables as your api token, user code and pipelineID.

All this information you will find it at lacrm.
