 
 request = require 'request'
 q = require 'q'
+
+PAGE_SIZE = 50
 
 transformResponse = (body) ->
   if !body


    request.get options, (error, response, body) ->
      try
        console.log "API returned:", body
        deferred.resolve transformResponse(body)
      catch error
        deferred.reject error

    return deferred.promise

  createPullRequest: (title, description, repoOwner, repoName, fromBranch, toBranch) ->
    deferred = q.defer()
    url = "#{API_URL}#{repoOwner}/#{repoName}/pullrequests"


  getBranches: (repoOwner, repoName) ->
    deferred = q.defer()
    url = "#{API_URL}#{repoOwner}/#{repoName}/refs/branches"

    @invokeTillHasNext(url, transformBranchResponse).then (result) ->
      deferred.resolve result

    return deferred.promise

