@getquanty/extension-api
v1.2.0
Published
Une API pour déclencher des actions dans des extensions Chrome de GetQuanty dans tout environnement.
Downloads
27
Readme
@getquanty/extension-api
An API for triggering contact and company search actions within the GetQuanty, and ClicSight extensions.
Installation
Install the package via NPM:
npm install @getquanty/extension-apiAPI Documentation
1. GetquantyApi Class
The main class for interacting with the extension.
Constructor
constructor(options: GetquantyApiOptions)Parameters:
options.extensionId(string, required): The ID of the extension. This is a unique identifier that is assigned to each Chrome extension. You can find theextensionIdby navigating tochrome://extensions/in your Chrome browser. Ensure that the Developer mode is enabled to view the ID of each installed extension. This ID is needed to reference the specific extension in your application.
2. Methods
searchCompany(params: CompanySearchParams): Promise<any>
Search for a company within the extension.
Parameters:
See the Searching for a Company section.
Return:
A Promise containing the extension's response or an error.
searchContact(params: ContactSearchParams): Promise<any>
Search for a contact within the extension.
Parameters:
See the Searching for a Contact section.
Return:
A Promise containing the extension's response or an error.
Error Handling
The searchCompany and searchContact methods return an error if:
- The extension ID is not valid.
- The extension is not accessible.
- Required parameters are missing or invalid.
Usage
1. Initialization
Create an instance of the GetquantyApi class by providing the extension ID.
Example:
import { GetquantyApi } from '@getquanty/extension-api';
const api = new GetquantyApi({ extensionId: 'extension-id' });GetquantyApiOptions
The GetquantyApiOptions interface is available for export for class initialization.
2. Checking if the Extension is Installed by the user
Use the isExtensionInstalled method to check if the extension is installed. A timeout of 15 seconds is applied to wait for a response before concluding the absence of the extension.
Example:
api.isExtensionInstalled()
.then(isInstalled => {
if (isInstalled) {
console.log('The extension is installed.');
} else {
console.log('The extension is not installed.');
}
})
.catch(error => {
console.error('Error checking if the extension is installed:', error);
});3. Searching for a Company
Use the searchCompany method to send a request to search for information about a company.
CompanySearchParams
The CompanySearchParams interface is available for export for the expected parameters.
Expected Parameters:
company(string, required): The name of the company.phone(string, optional): The company's phone number.email(string, optional): The company's email.website(string, required): The company's website.domain(string, optional): The associated domain.siret(string, optional): The SIRET number of the company.siren(string, optional): The SIREN number of the company.company_id(string, optional): Special case: GetQuanty relies on external data.
Example:
api.searchCompany({
company: "My Company",
phone: "+123456789",
website: "https://mycompany.com",
domain: "mycompany.com",
siret: "12345678900012",
siren: "123456789"
}).then(response => {
console.log("Company search result:", response);
}).catch(error => {
console.error("Error:", error);
});4. Searching for a Contact
Use the searchContact method to send a request to search for information about a contact.
ContactSearchParams
The ContactSearchParams interface is available for export for the expected parameters.
Expected Parameters:
fullname(string, optional): The full name of the contact.firstname(string, required): The first name of the contact.lastname(string, required): The last name of the contact.company(string, optional): The associated company.linkedin(string, optional): The LinkedIn profile URL of the contact.position(string, optional): The contact's position or role.email(string, required): The contact's email.phone(string, optional): The contact's phone number.contact_id(string, optional): Special case: GetQuanty relies on external data.
Example:
api.searchContact({
fullname: "Jane Doe",
firstname: "Jane",
lastname: "Doe",
company: "Tech Corp",
linkedin: "https://linkedin.com/in/janedoe",
position: "CTO",
email: "[email protected]",
phone: "+987654321"
}).then(response => {
console.log("Contact search result:", response);
}).catch(error => {
console.error("Error:", error);
});5. Browser (UMD) Usage
If you are using the UMD version directly in a browser, add the index.umd.js file to your project and use the API via the global object GetQuantyExtensionAPI.
HTML Example:
<script src="path/to/index.umd.js"></script>
<script>
const api = new GetQuantyExtensionAPI.GetquantyApi({ extensionId: 'your-extension-id' });
api.searchCompany({
company: "My Company",
website: "https://mycompany.com"
}).then(response => {
console.log("Company search result:", response);
}).catch(error => {
console.error("Error:", error);
});
</script>