Source

ocaml-bitbucket / api.ml

Diff from to
 open Common
+open Json_wrap
+open Json_conv
 
 module Scheme = struct
-  type t = [ `hg | `git ] with json
-
-  let of_json = t_of_json
-  let to_json = json_of_t
+  type t = Hg(hg) | Git(git) with conv(json)
 end
 
-module Repository = struct
- 
-  type t = { 
-    owner      : string;
-    scm        : Scheme.t;
-    slug       : string;
-    is_private : bool;
-    name       : string
-  }
+module User = struct
 
-  and ts = t list
+  module Repository = struct
+   
+    type t = { 
+      owner      : string;
+      scm        : Scheme.t;
+      slug       : string;
+      is_private : bool;
+      name       : string
+    }
+  
+    and ts = t list
+  
+    with conv(json)
+  
+  end
 
-  with json
+  module Repositories = struct
 
-  let get_ts ~user ~password = 
-    ts_of_json (Json_io.json_of_string (Curl.get_string (fun h ->
-      h#set_url "https://api.bitbucket.org/1.0/user/repositories/";
-      h#set_userpwd (Printf.sprintf "%s:%s" user password))))
+    type t = Repository.t list with conv(json)
+
+    let get ~user ~password = 
+      t_of_json (Json_io.json_of_string (Curl.get_string (fun h ->
+        h#set_url "https://api.bitbucket.org/1.0/user/repositories/";
+        h#set_userpwd (Printf.sprintf "%s:%s" user password))))
+  end
+
 end