File

projects/congarevenuecloud/ecommerce/src/lib/modules/catalog/services/attachment.service.ts

Description

The attachment represents a file that can be associated with an order, quote, etc as an attachment.

Extends

AObjectService

Index

Properties
Methods

Methods

checkSupportedFileType
checkSupportedFileType(fileList: FileList, supportedFileTypes: string)

This method is used to check supported file type

Parameters :
Name Type Optional Description
fileList FileList No

The files to be checked for supported file types.

supportedFileTypes string No

A string containing supported file extensions.

Returns : boolean

true if at least one file in the filelist is of a supported file type.

deleteAttachment
deleteAttachment(documentId: string)

Method to delete the attachment for quote, order, etc using the Id of the document.

Example:

Example :
import { AttachmentService, Attachment } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{

constructor(private attachmentService: AttachmentService){}

ngOnInit(){
this.attachmentService.deleteAttachment(documentId: string).subscribe((res) => {
});
}
}
Parameters :
Name Type Optional Description
documentId string No

Id of the document to be deleted.

Returns : Observable<boolean>

an observable of the boolean on successful delete.

generateDocument
generateDocument(templateId: string, object: AObject, type: "Order" | "Proposal", format: "PDF" | "PDF/A" | "DOCX", watermark: boolean)

Method generates a document for a given quote record based on a template.

Example:

Example :

import { AttachmentService, TemplateService } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';
export class MyComponent implements OnInit{

constructor(private attachmentService: AttachmentService, private templateService: TemplateService){}

generateDocumentForQuote(quote: Quote){
this.templateService.getActiveTemplates('Proposal')
.take(1)
.subscribe(templateList => {
this.attachmentService.generateDocument(templateList[0], quote, 'Proposal', 'DOC', true).subscribe(
() => {...},
err => {...}
);
});
}
}
Parameters :
Name Type Optional Default value Description
templateId string No

The id of the template record with which to generate the document

object AObject No

the instance of the quote or order AObject to generate the document from

type "Order" | "Proposal" No

determines the type of the document, accepts string 'Order' for Order Object or 'Proposal' for Quote object

format "PDF" | "PDF/A" | "DOCX" No 'PDF'

the format of the document to create

watermark boolean No false

to include configured watermark, by default it is false.

Returns : Observable<Job>

observable object of the generated document with job details.

getAttachments
getAttachments(parentId: string, parentObjectName: string, sortBy: string, sortDirection: "asc" | "desc")

Retrieves attachments associated with a object.

Example:

Example :
import { AttachmentService, Attachment } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{

constructor(private attachmentService: AttachmentService){}

ngOnInit(){
this.attachmentService.getAttachments(parentId: string, parentObjectName: string).subscribe((res) => {
});
}
}

@param parentObjectName string representing parent object name @param sortBy string representing the field on the attachment record to sort attachments by. By default the attachments will be sorted based on the creation date. @param sortDirection fetch the records based on asc | desc directions.By default it is descending. @returns An Observable emitting an array of Attachment objects.

Parameters :
Name Type Optional Default value Description
parentId string No

string identifier of the parent object.

parentObjectName string No

string representing parent object name

sortBy string No 'CreatedDate'

string representing the field on the attachment record to sort attachments by. By default the attachments will be sorted based on the creation date.

sortDirection "asc" | "desc" No 'desc'

fetch the records based on asc | desc directions.By default it is descending.

An Observable emitting an array of Attachment objects.

getDocumentStatus
getDocumentStatus(jobId: string)

Method fetches the status of the document.

Example:

Example :

import { AttachmentService, TemplateService } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';
export class MyComponent implements OnInit{

constructor(private attachmentService: AttachmentService, private templateService: TemplateService){}

getDocumentStatus(jobId:string){
this.attachmentService.getDocumentStatus(jobId).subscribe(
() => {...},
err => {...}
);
});
}
}
Parameters :
Name Type Optional Description
jobId string No

The job Id of the attachment to be passed.

Returns : Observable<any>

observable of object with success or failure status of the attachment.

getSupportedAttachmentType
getSupportedAttachmentType()

This method is responsible for fetching all valid file extensions supported by Conga platform.

Returns : Observable<string>

An Observable emitting an array of string that contains valid file extensions

uploadAttachment
uploadAttachment(file: File, isPrivate: boolean, parentId: string, parentObjectName: string)

Method to upload the attachment for quote, order, etc and associate with given parent id

Example:

Example :
import { AttachmentService, Attachment } from '@congarevenuecloud/ecommerce';
import { Observable } from 'rxjs/Observable';

export class MyComponent implements OnInit{

constructor(private attachmentService: AttachmentService){}

ngOnInit(){
this.attachmentService.uploadAttachment(file: File, parentId: string).subscribe((res) => {
});
}
}
Parameters :
Name Type Optional Default value Description
file File No

file to upload as an attachment for given parent id

isPrivate boolean No false

boolean to specify the visibility of uploaded attachment. Defaulted to false

parentId string No

id of associted parent of an attachment

parentObjectName string No

string representing the object name

an observable of the uploaded attached with id, errors and status

Properties

type
Default value : DocumentMetadata
Protected userService
Type : UserService
Default value : this.injector.get(UserService)

results matching ""

    No results matching ""