all files / lib/templates/ ReceiptTemplate.js

100% Statements 0/0
100% Branches 0/0
100% Functions 0/0
100% Lines 0/0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43                                                                                     
class ReceiptTemplate {
  constructor({ recipient_name, order_number, currency, payment_method,
                elements, summary, timestamp = '', order_url = '', address = '',
                adjustments = [] }) {
    this.recipient_name = recipient_name;
    this.order_number = order_number;
    this.currency = currency;
    this.payment_method = payment_method;
    this.elements = elements;
    this.summary = summary;
    this.timestamp = timestamp;
    this.order_url = order_url;
    this.address = address;
    this.adjustments = adjustments;
 
    const res = {
      attachment: {
        type: 'template',
        payload: {
          template_type: 'receipt',
          recipient_name: this.recipient_name,
          order_number: this.order_number,
          currency: this.currency,
          payment_method: this.payment_method,
          order_url: this.order_url,
          timestamp: this.timestamp,
          elements: this.elements,
          address: this.address,
          summary: this.summary,
        },
      },
    };
 
    if (this.adjustments) {
      res.attachment.payload.adjustments = this.adjustments;
    }
 
    return res;
  }
}
 
export default ReceiptTemplate;