<commit_before><dom-module id="shape-iron-ajax-helper">
  <template>
    <iron-ajax
            id="loginCall"
            url="{{computePath(baseURL, resource)}}"
            method="{{method}}"
            handle-as="json"
            content-type="application/json"
            on-response="loginCallBack"
            on-error="handleError"
    >
    </iron-ajax>
    <iron-ajax
            id="secureCall"
            url="{{computePath(baseURL, resource)}}"
            on-response="handleResponse"
            method="{{method}}"
            content-type="{{contentType}}"
            handle-as="json"
            body="{{body}}"
            on-error="handleError"
    >
    </iron-ajax>
    <iron-ajax
            id="passwordResetCall"
            url="{{computePath(baseURL, resource)}}"
            on-response="handleResponse"
            method="{{method}}"
            content-type="{{contentType}}"
            handle-as="json"
            body="{{body}}"
            on-error="handleError"
    >
    </iron-ajax>


  </template>
</dom-module>
  <script>
    (function () {
      Polymer({
        is: 'shape-iron-ajax-helper',
        properties: {
          resource: {
            type: String
          },
          body: String,
          // baseUrl: {
          //   type: String,
          //   value: 'http://popdemo.ehealthconnecticut.org:8080/shape-service/shape'
          // },
          baseUrl: {
            type: String,
            value: 'http://localhost:8080/shape-service/shape'
          },

          callId: {
            type: String,
            value: 'testCall'
          },
          method: {
            type: String
          },
          contentType: {
            type: String,
            value: "application/JSON"
          },
          errorMessage:{
            type: String
          }
        },
        computePath: function(baseURL,resource) {
          return baseURL+resource
        },
        handleResponse: function(request) {

        },
        generateRequest: function(){
          //set header
          this.$.secureCall.headers={
            "Authorization": "Bearer "+this.getToken()
          };
          this.$.secureCall.url=this.computePath(this.baseUrl, this.resource)
          //create request
          this.$.secureCall.generateRequest()

        },
        generatePasswordResetRequest: function(){
          //set header
          this.$.passwordResetCall.url=this.computePath(this.baseUrl, this.resource)
          //create request
          this.$.passwordResetCall.generateRequest()

        },
        ready: function() {

        },
        handleError: function(evt){
          errorMessage = evt.detail.request.parseResponse().errMsg;
          app.$.errorDialogBox.openError(errorMessage);
          // document.querySelector('app-error-dialog').openError;
        },
        login: function(userId, password){
          resource='/common/login/'; //set the resource location
          this.method="POST"
          this.$.loginCall.url=this.computePath(this.baseUrl, resource)
          this.$.loginCall.body=JSON.stringify(
                  {
                    "userId": userId,
                    "password": password
                  })
          //this.callBack=this.loginCallBack;
          this.$.loginCall.generateRequest()
        },
        loginCallBack: function(response){
          if (event.detail.response.token) {
            localStorage.token = event.detail.response.token
            if (this.callBack) {
              this.callBack()
            }
          }else{
            alert("No token came back")
          }
        },
        // closeError: function(){
        //   app.select='login'
        //   app.$.errorDialog.toggle()
        // },
        getToken: function(){
          //check if local storage is available on this browser
          if(typeof(Storage) !== "undefined") {
            if (localStorage.token){ //Check if the token is set
              return localStorage.token // return the token that is stored
            }else{
              //Alert the user that they need to be logged in
              alert("You are not logged in");
            }
          } else {
              // Sorry! No Web Storage support..
              alert("You must update your browser to use this application.");
          }
        }
        });


        //});
    })();
  </script>
<commit_msg>URL is set in shape-iron-ajax-helper<commit_after><dom-module id="shape-iron-ajax-helper">
  <template>
    <iron-ajax
            id="loginCall"
            url="{{computePath(baseURL, resource)}}"
            method="{{method}}"
            handle-as="json"
            content-type="application/json"
            on-response="loginCallBack"
            on-error="handleError"
    >
    </iron-ajax>
    <iron-ajax
            id="secureCall"
            url="{{computePath(baseURL, resource)}}"
            on-response="handleResponse"
            method="{{method}}"
            content-type="{{contentType}}"
            handle-as="json"
            body="{{body}}"
            on-error="handleError"
    >
    </iron-ajax>
    <iron-ajax
            id="passwordResetCall"
            url="{{computePath(baseURL, resource)}}"
            on-response="handleResponse"
            method="{{method}}"
            content-type="{{contentType}}"
            handle-as="json"
            body="{{body}}"
            on-error="handleError"
    >
    </iron-ajax>


  </template>
</dom-module>
  <script>
    (function () {
      Polymer({
        is: 'shape-iron-ajax-helper',
        properties: {
          resource: {
            type: String
          },
          body: String,
          // baseUrl: {
          //   type: String,
          //   value: 'http://popdemo.ehealthconnecticut.org:8080/shape-service/shape'
          // },
          baseUrl: {
            type: String,
            value: 'http://192.168.0.23/shape-service/shape'
          },

          callId: {
            type: String,
            value: 'testCall'
          },
          method: {
            type: String
          },
          contentType: {
            type: String,
            value: "application/JSON"
          },
          errorMessage:{
            type: String
          }
        },
        computePath: function(baseURL,resource) {
          return baseURL+resource
        },
        handleResponse: function(request) {

        },
        generateRequest: function(){
          //set header
          this.$.secureCall.headers={
            "Authorization": "Bearer "+this.getToken()
          };
          this.$.secureCall.url=this.computePath(this.baseUrl, this.resource)
          //create request
          this.$.secureCall.generateRequest()

        },
        generatePasswordResetRequest: function(){
          //set header
          this.$.passwordResetCall.url=this.computePath(this.baseUrl, this.resource)
          //create request
          this.$.passwordResetCall.generateRequest()

        },
        ready: function() {

        },
        handleError: function(evt){
          errorMessage = evt.detail.request.parseResponse().errMsg;
          app.$.errorDialogBox.openError(errorMessage);
          // document.querySelector('app-error-dialog').openError;
        },
        login: function(userId, password){
          resource='/common/login/'; //set the resource location
          this.method="POST"
          this.$.loginCall.url=this.computePath(this.baseUrl, resource)
          this.$.loginCall.body=JSON.stringify(
                  {
                    "userId": userId,
                    "password": password
                  })
          //this.callBack=this.loginCallBack;
          this.$.loginCall.generateRequest()
        },
        loginCallBack: function(response){
          if (event.detail.response.token) {
            localStorage.token = event.detail.response.token
            if (this.callBack) {
              this.callBack()
            }
          }else{
            alert("No token came back")
          }
        },
        // closeError: function(){
        //   app.select='login'
        //   app.$.errorDialog.toggle()
        // },
        getToken: function(){
          //check if local storage is available on this browser
          if(typeof(Storage) !== "undefined") {
            if (localStorage.token){ //Check if the token is set
              return localStorage.token // return the token that is stored
            }else{
              //Alert the user that they need to be logged in
              alert("You are not logged in");
            }
          } else {
              // Sorry! No Web Storage support..
              alert("You must update your browser to use this application.");
          }
        }
        });


        //});
    })();
  </script>

{'fraction_non_alphanumeric': 0.12998306041784302, 'fraction_numerical': 0.0023715415019762848, 'mean_word_length': 1.4565880721220528, 'pattern_counts': {'":': 6, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3525484', 'n_tokens_mistral': 2291, 'n_tokens_neox': 2260, 'n_words': 418}