class Geet::Github::PR
def self.list(api_interface, milestone: nil, assignee: nil, owner: nil, head: nil, &type_filter)
def self.list(api_interface, milestone: nil, assignee: nil, owner: nil, head: nil, &type_filter) check_list_params!(milestone, assignee, head) if head api_path = 'pulls' # Technically, the upstream approach could be used for both, but it's actually good to have # both of them as reference. # # For upstream pulls, the owner is the authenticated user, otherwise, the repository owner. # response = if api_interface.upstream? unfiltered_response = T.cast( api_interface.send_request(api_path, multipage: true), T::Array[T::Hash[String, T.untyped]] ) # VERY weird. From the docs, it's not clear if the user/org is required in the `head` parameter, # but: # # - if it isn't included (eg. `anything`), the parameter is ignored # - if it's included (eg. `saveriomiroddi:local_branch_name`), an empty resultset is returned. # # For this reason, we can't use that param, and have to filter manually. # unfiltered_response.select do |pr_data| pr_head = T.cast(pr_data.fetch('head'), T::Hash[String, T.untyped]) label = T.cast(pr_head.fetch('label'), String) label == "#{owner}:#{head}" end else request_params = {head: "#{owner}:#{head}"} T.cast( api_interface.send_request(api_path, params: request_params, multipage: true), T::Array[T::Hash[String, T.untyped]] ) end response.map do |pr_data| number = T.cast(pr_data.fetch('number'), Integer) title = T.cast(pr_data.fetch('title'), String) link = T.cast(pr_data.fetch('html_url'), String) new(number, api_interface, title, link) end else result = super(api_interface, milestone:, assignee:) do |issue_data| issue_data.key?('pull_request') end T.cast(result, T::Array[Geet::Github::PR]) end end