package com.sinewang.statemate.core.spi;

import one.kii.statemate.core.spi.SubscribeModelSpi;
import one.kii.summer.erest.ErestPost;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * Created by WangYanJiong on 09/04/2017.
 */
@Component
@ConfigurationProperties(prefix = "metamate")
public class DefaultSubscribeModelSpi implements SubscribeModelSpi {


    private static String URI = "/{subscriberId}/subscribe";

    private String baseUrl;

    private String subscriberId;

    private String operatorId;

    public void setBaseUrl(String baseUrl) {
        this.baseUrl = baseUrl;
    }

    public void setSubscriberId(String subscriberId) {
        this.subscriberId = subscriberId;
    }

    public void setOperatorId(String operatorId) {
        this.operatorId = operatorId;
    }

    @Override
    public Receipt subscribe(Form form) {
        String url = baseUrl + URI;

        ErestPost erest = new ErestPost(operatorId);

        return erest.execute(url, form, Receipt.class, form.getSubscriberId());
    }
}

@@ -127,16 +127,73 @@
 stPost;%0A
+import org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A
 import o
@@ -291,28 +291,169 @@
 ork.
-stereotype.Component
+http.MediaType;%0Aimport org.springframework.http.ResponseEntity;%0Aimport org.springframework.stereotype.Component;%0Aimport org.springframework.web.bind.annotation.*
 ;%0A%0A/
@@ -628,16 +628,108 @@
 lSpi %7B%0A%0A
+    private static Logger logger = LoggerFactory.getLogger(DefaultSubscribeModelSpi.class);%0A
 %0A    pri
@@ -1308,16 +1308,84 @@
 torId);%0A
+        logger.info(%22url:%7B%7D, variables:%7B%7D%22, form.getSubscriberId());
 %0A       
@@ -1464,9 +1464,8 @@
 %0A    %7D%0A%7D
-%0A

update log