highcourt-affidavit
v1.0.5
Published
[](https://opensource.org/licenses/MIT) [](https://www.npmjs.com/package/highcourt-affidavit) [ that can be easily customized and integrated to manage the creation of affidavits.
Features
- Effortless Integration: Seamlessly integrate affidavit creation into your Angular application with minimal setup
- Customizable Component: Tailor the
highcourt-affidavitcomponent to match your specific requirements and workflows - Bulk Operations: Create multiple affidavits at once using the bulk creation component
- Service-based API: Use the service directly for programmatic affidavit creation
- Clear Documentation: Comprehensive documentation and examples to guide you through the library's usage
- Error Handling: Built-in error handling mechanisms to address potential issues during affidavit creation
- TypeScript Support: Full TypeScript support with type definitions
Prerequisites
- Angular 16 or higher
- Node.js 18 or higher
- npm or yarn package manager
Installation
Install using npm:
npm install highcourt-affidavitOr using yarn:
yarn add highcourt-affidavit
2. Import the Module
In your Angular app, import the HighcourtAffidavitModule in your app module or any other relevant module where you want to use the affidavit functionality. Pass your API keys from the environment configuration:
import { NgModule } from "@angular/core";
import { HighcourtAffidavitModule } from "highcourt-affidavit";
import { environment } from "../environments/environment";
@NgModule({
imports: [
HighcourtAffidavitModule.forRoot(environment.affidavit_api_secret_key, environment.mode), // Both token and mode arguments are optional
],
// ...
})
export class AppModule {}Note: Make sure to set the
affidavit_api_secret_keyandaffidavit_api_public_keyin your environment files.
3. Integration Methods
You can integrate the affidavit functionality using either the component-based approach or the service-based approach.
Option 1: Component-based Integration
Single Affidavit Creation
Integrate the highcourt-affidavit component into your HTML template, optionally configuring it with token and mode properties. Capture its output using the event callback for further processing.
<highcourt-affidavit (callBack)="getApp($event)" [token]="'FHC_sk_xxxxxxxx-xxxxxx'" [mode]="'production'"> </highcourt-affidavit>export class MyComponent {
getApp(data: any) {
console.log("Application", data);
// Handle the affidavit creation response
}
}Bulk Affidavit Creation
To create multiple affidavits at once, use the e-affidavit-bulk-create-applications component. Provide a payload, affidavitTemplateId, and a unique client_ref.
<e-affidavit-bulk-create-applications [payload]="affidavitPayload" [affidavitTemplateId]="55" [client_ref]="'POSSAP-0023-2343243212211'" (callBack)="getApp($event)"> </e-affidavit-bulk-create-applications>export class MyComponent {
affidavitPayload = [
{
deponent_name: "John Doe",
deponent_nin: 12345678912,
// ... other required fields
},
];
getApp(data: any) {
console.log("Bulk Application", data);
// Handle the bulk affidavit creation response
}
}View Application Details
You can also navigate directly to the details of an affidavit application using the client_ref and page parameters:
<e-affidavit-bulk-create-applications [page]="'details'" [client_ref]="'POSSAP-0023-2343243212211'"> </e-affidavit-bulk-create-applications>Option 2: Service-based Integration
If you prefer a programmatic approach, use the HighcourtAffidavitLibraryService to create affidavits via a service call:
import { Component } from "@angular/core";
import { HighcourtAffidavitLibraryService } from "highcourt-affidavit";
@Component({
selector: "app-create-affidavit",
templateUrl: "./create-affidavit.component.html",
})
export class CreateAffidavitComponent {
constructor(private affidavitService: HighcourtAffidavitLibraryService) {}
createAffidavit() {
const affidavitData = {
affidavit_type_name: "Affidavit of Ownership",
deponent_name: "Ahmad Ibrahim",
deponent_nin: 12345678912,
town_native: "Gusau",
town_resident: "Gusau",
occupation: "Software Developer",
gender: "Male",
religion: "Islam",
signature_file: "signature.png", // Should be provided in binary format
passport_photo_file: "passport.jpg", // Should be provided in binary format
identity_photo_file: "id-card.jpeg", // Should be provided in binary format
applicant_email: "[email protected]",
applicant_phone: "07066666666",
adult_minor: "adult",
affidavit_template_id: 1,
lga_id: 1,
court_id: 1,
formEntries: [
{
placeholder: "fullName",
label: "Full Name",
provided_value: "Ahmad Ibrahim",
},
],
clauseEntries: [{ entry: "Affidavit Clause" }],
};
this.affidavitService.create(affidavitData).subscribe({
next: (response) => {
console.log("Affidavit Created:", response);
// Handle successful creation
},
error: (error) => {
console.error("Affidavit Creation Failed:", error);
// Handle error
},
});
}
createBulkAffidavit() {
const affidavitData = {
affidavit_type_name: "Affidavit of Ownership",
affidavit_template_id: 1,
applicant_email: "[email protected]",
applicant_phone: "07066666666",
court_id: 1,
applications: [
{
deponent_name: "Ahmad Ibrahim",
deponent_nin: 12345678912,
town_native: "Gusau",
town_resident: "Gusau",
occupation: "Software Developer",
gender: "Male",
religion: "Islam",
signature_file: "signature.png", // Should be provided in binary format
passport_photo_file: "passport.jpg", // Should be provided in binary format
identity_photo_file: "id-card.jpeg", // Should be provided in binary format
lga_id: 1,
court_id: 1,
formEntries: [
{
placeholder: "fullName",
label: "Full Name",
provided_value: "Ahmad Ibrahim",
},
],
clauseEntries: [{ entry: "Affidavit Clause" }],
},
],
};
this.affidavitService.createBulk(affidavitData).subscribe({
next: (response) => {
console.log("Affidavits Created:", response);
// Handle successful bulk creation
},
error: (error) => {
console.error("Affidavits Creation Failed:", error);
// Handle error
},
});
}
}Note: Make sure to set the
affidavit_api_secret_keyandaffidavit_api_public_keyin your environment files.
4. Add Styles
To ensure your application uses the correct styles for PrimeNG components and the affidavit library, import the following styles in your global styles.scss file:
@import "~primeng/resources/primeng.min.css";
@import "~primeflex/primeflex.scss";
@import "~primeicons/primeicons.css";
@import "~highcourt-affidavit/src/lib/styles.scss";
@import url("https://fonts.googleapis.com/css?family=Comfortaa");5. Environment Configuration
Ensure you have set your API keys in the environment files. These keys are required for the affidavit service to function correctly:
export const environment = {
production: false,
affidavit_api_secret_key: "your_secret_key",
affidavit_api_public_key: "your_public_key",
mode: "test", // Can be either 'production' or 'test'
};6. API Reference
Components
highcourt-affidavit
The main component for creating single affidavits.
Properties:
token(optional): Your API secret keymode(optional): Environment mode ('production' or 'test')
Events:
callBack: Emitted when affidavit creation is completed
e-affidavit-bulk-create-applications
Component for creating multiple affidavits at once.
Properties:
payload: Array of affidavit data objectsaffidavitTemplateId: Template ID for the affidavitsclient_ref: Unique reference for the bulk operationpage(optional): Set to 'details' to view application detailstoken(optional): Your API secret keymode(optional): Environment mode
Events:
callBack: Emitted when bulk affidavit creation is completed
Services
HighcourtAffidavitLibraryService
Service for programmatic affidavit creation.
Methods:
create(affidavitData): Create a single affidavitcreateBulk(affidavitData): Create multiple affidavits
7. Data Models
Affidavit Data Structure
interface AffidavitData {
affidavit_type_name: string;
deponent_name: string;
deponent_nin: number;
town_native: string;
town_resident: string;
occupation: string;
gender: string;
religion: string;
signature_file: string; // Binary format
passport_photo_file: string; // Binary format
identity_photo_file: string; // Binary format
applicant_email: string;
applicant_phone: string;
adult_minor: "adult" | "minor";
affidavit_template_id: number;
lga_id: number;
court_id: number;
formEntries: FormEntry[];
clauseEntries: ClauseEntry[];
}
interface FormEntry {
placeholder: string;
label: string;
provided_value: string;
}
interface ClauseEntry {
entry: string;
}8. Troubleshooting
Common Issues
Module not found error: Ensure you have installed the package correctly using npm or yarn.
API key errors: Verify that your API keys are correctly set in the environment files.
Styling issues: Make sure you have imported all required styles in your global styles file.
File upload issues: Ensure that file uploads are in binary format as required by the API.
Getting Help
If you encounter any issues or need assistance:
- Check the NPM page
- Review the API documentation
- Contact support at [email protected] or visit Century Information Systems Contact
9. Contributing
We welcome contributions! For more information about contributing to this project, please contact us at [email protected] or visit Century Information Systems.
11. Changelog
Version 1.0.0
- Initial release
- Single affidavit creation
- Bulk affidavit creation
- Service-based integration
- Component-based integration
