public function handle_note_and_send_by_email($sendByEmail, $type, $id, $entry)
 {
     if ($type == 'invoice') {
         $invoice_estimate = new FreshBooks_Invoice();
         $invoice_estimate->invoiceId = $id;
     } elseif ($type == 'estimate') {
         $invoice_estimate = new FreshBooks_Estimate();
         $invoice_estimate->estimateId = $id;
     } else {
         // abort, no need to sendByEmail or add note.
         return;
     }
     // see if invoice/estimate should automatically be emailed.
     if ($sendByEmail) {
         $this->log_debug(__METHOD__ . '(): Sending invoice/estimate automatically by email.');
         $sentByEmail = $invoice_estimate->sendByEmail();
         if ($sentByEmail) {
             $this->log_debug(__METHOD__ . '(): The invoice/estimate was successfully scheduled to be automatically sent by FreshBooks.');
         } else {
             $this->log_error(__METHOD__ . '(): Unable to schedule invoice/estimate to be automatically sent.');
         }
     }
     // add note to entry.
     $invoice_estimate->get($id);
     $amount_formatted = GFCommon::to_money($invoice_estimate->amount, $entry['currency']);
     $note = sprintf(__('%s #%s has been successfully created. Amount: %s. Status: %s.', 'gravityformsfreshbooks'), ucfirst($type), $invoice_estimate->number, $amount_formatted, ucfirst($invoice_estimate->status));
     GFFormsModel::add_note($entry['id'], 0, $this->_short_title, $note, 'success');
 }