Source

ocaml-bitbucket / api.ml

open Common
open Json_wrap
open Json_conv

module Scheme = struct
  type t = Hg(hg) | Git(git) with conv(json)
end

module User = struct

  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

  module Repositories = struct

    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