RooTicket.vala
authorAlan Knowles <alan@roojs.com>
Mon, 17 Dec 2018 07:47:34 +0000 (15:47 +0800)
committerAlan Knowles <alan@roojs.com>
Mon, 17 Dec 2018 07:47:34 +0000 (15:47 +0800)
RooTicket.vala

index 4f81e20..fd53f6b 100644 (file)
@@ -595,6 +595,65 @@ public class RooTicket : Object
                }
 
    }
+       public string createTicket(     
+                       string project_id,
+                       string milestone_id,
+                       string priority_id,
+                       string classification_id,
+                       string developer_id,
+                       string summary,
+                       string description
+               ) 
+       {
+               if (this.id == "-1") {
+                       return;
+               }
+               var table = new GLib.HashTable<string, string>(str_hash, str_equal);
+                ;
+                
+               table.insert("project_id", project_id);
+               table.insert("milestone_id", milestone_id);
+               table.insert("priority_id", priority_id);
+               table.insert("classification_id", classification_id);
+               table.insert("developer_id", developer_id);
+               table.insert("summary", summary);
+               table.insert("description", description);
+                
+               var params = Soup.Form.encode_hash(table);              
+
+               GLib.debug("request POST %s / %s", roourl, id);
+
+               var session = new Soup.Session ();
+               session.timeout = 0;
+               var message = new Soup.Message ("POST", roourl + "/mtrack_ticket");
+               RooTicket.setAuth(message);
+
+               message.set_request ("application/x-www-form-urlencoded", Soup.MemoryUse.STATIC, params.data);
+               session.send_message (message);
+
+
+               var data = (string) message.response_body.flatten().data;
+               GLib.debug("got %s", data);
+               try {
+                          var parser = new Json.Parser ();
+                          parser.load_from_data (data, -1);
+
+                          var response = parser.get_root().get_object();
+                          var status = response.get_boolean_member("success");
+
+                          if(!status){
+                                          GLib.error(response.get_string_member("errorMsg"));
+                                          return ;
+                          }
+                               
+                          
+                               
+
+               } catch (Error e) {
+                          GLib.error(e.message);
+                          return ;
+               }
+   
 
        
 }