'use strict';

var apiService = require('../apiService').getInstance();

function FinishOrderResponse() {
}

FinishOrderResponse.prototype = {
    getResponse: function (productId, intervalId, userId) {
        var product = apiService.getProduct(productId);
        var order = apiService.registerOrder(productId, intervalId, userId);
        console.log(order);
        var response = {
            attachment: {
                type: "template",
                payload: {
                    template_type: "receipt",
                    recipient_name: userId,
                    order_number: order.orderId,
                    currency: "USD",
                    payment_method: "Visa 2345",
                    order_url: "http://petersapparel.parseapp.com/order?order_id=123456",
                    timestamp: "1428444852",
                    elements: [
                        {
                            "title": product.name,
                            "subtitle": product.description,
                            "quantity": 1,
                            "price": product.price,
                            "currency": "RON",
                            "image_url": product.image
                        }
                    ]
                }
            }
        };

        return JSON.stringify(response);
    }
};

/**
 * @returns {FinishOrderResponse}
 */
module.exports.getInstance = function () {
    return new FinishOrderResponse();
};

@@ -378,24 +378,51 @@
 esponse = %7B%0A
+            message: %7B%0A    
             
@@ -431,24 +431,28 @@
 tachment: %7B%0A
+    
             
@@ -489,16 +489,20 @@
         
+ 
+   
 payload:
@@ -500,24 +500,28 @@
  payload: %7B%0A
+    
             
@@ -574,16 +574,20 @@
         
+ 
+   
 recipien
@@ -598,24 +598,28 @@
 me: userId,%0A
+    
             
@@ -675,16 +675,20 @@
         
+ 
+   
 currency
@@ -696,16 +696,20 @@
  %22USD%22,%0A
+    
         
@@ -749,16 +749,20 @@
  2345%22,%0A
+    
         
@@ -843,16 +843,20 @@
 23456%22,%0A
+    
         
@@ -912,16 +912,20 @@
         
+    
 elements
@@ -928,16 +928,20 @@
 ents: %5B%0A
+    
         
@@ -986,16 +986,20 @@
         
+    
 %22title%22:
@@ -1013,16 +1013,20 @@
 t.name,%0A
+    
         
@@ -1106,16 +1106,20 @@
         
+    
 %22quantit
@@ -1125,16 +1125,20 @@
 ty%22: 1,%0A
+    
         
@@ -1209,16 +1209,20 @@
         
+    
 %22currenc
@@ -1260,16 +1260,20 @@
         
+   
+ 
 %22image_u
@@ -1307,32 +1307,36 @@
                 
+    
 %7D%0A              
@@ -1345,9 +1345,35 @@
     
-%5D
+    %5D%0A                    %7D
 %0A   

add notifier