All files / output zcl_abapgit_pr_enum_github.clas.mjs

7.64% Statements 24/314
66.66% Branches 2/3
5.88% Functions 1/17
7.64% Lines 24/314

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 3141x 1x                                       1x 1x                   1x 1x 1x 1x 1x                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x
const {cx_root} = await import("./cx_root.clas.mjs");
// zcl_abapgit_pr_enum_github.clas.abap
class zcl_abapgit_pr_enum_github {
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'ZCL_ABAPGIT_PR_ENUM_GITHUB';
  static IMPLEMENTED_INTERFACES = ["ZIF_ABAPGIT_PR_ENUM_PROVIDER"];
  static ATTRIBUTES = {"MI_HTTP_AGENT": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_HTTP_AGENT", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_HTTP_AGENT"});}, "visibility": "I", "is_constant": " ", "is_class": " "},
  "MV_REPO_URL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "visibility": "I", "is_constant": " ", "is_class": " "},
  "MV_USER_AND_REPO": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "visibility": "I", "is_constant": " ", "is_class": " "}};
  static METHODS = {"FETCH_REPO_BY_URL": {"visibility": "I", "parameters": {"RS_INFO": {"type": () => {return new abap.types.Structure({
  "repo_json": new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_AJSON", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_AJSON"}),
  "pulls": abap.types.TableFactory.construct(new abap.types.Structure({
  "base_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-BASE_URL"}),
  "number": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-NUMBER"}),
  "title": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-TITLE"}),
  "user": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-USER"}),
  "head_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HEAD_URL"}),
  "head_branch": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HEAD_BRANCH"}),
  "created_at": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-CREATED_AT"}),
  "is_for_upstream": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}),
  "draft": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}),
  "html_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HTML_URL"})}, "zif_abapgit_pr_enum_provider=>ty_pull_request", undefined, {}, {}), {"withHeader":false,"keyType":"USER","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":["BASE_URL","NUMBER"]},"secondary":[]}, "zif_abapgit_pr_enum_provider=>ty_pull_requests")}, "zcl_abapgit_pr_enum_github=>ty_info", undefined, {}, {});}, "is_optional": " "}, "IV_REPO_URL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}},
  "CONVERT_LIST": {"visibility": "I", "parameters": {"RT_PULLS": {"type": () => {return abap.types.TableFactory.construct(new abap.types.Structure({
  "base_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-BASE_URL"}),
  "number": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-NUMBER"}),
  "title": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-TITLE"}),
  "user": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-USER"}),
  "head_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HEAD_URL"}),
  "head_branch": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HEAD_BRANCH"}),
  "created_at": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-CREATED_AT"}),
  "is_for_upstream": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}),
  "draft": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}),
  "html_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HTML_URL"})}, "zif_abapgit_pr_enum_provider=>ty_pull_request", undefined, {}, {}), {"withHeader":false,"keyType":"USER","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":["BASE_URL","NUMBER"]},"secondary":[]}, "zif_abapgit_pr_enum_provider=>ty_pull_requests");}, "is_optional": " "}, "II_JSON": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_AJSON", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_AJSON"});}, "is_optional": " "}}},
  "CLEAN_URL": {"visibility": "I", "parameters": {"RV_URL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "IV_URL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}},
  "CONSTRUCTOR": {"visibility": "U", "parameters": {"IV_USER_AND_REPO": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "II_HTTP_AGENT": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_HTTP_AGENT", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_HTTP_AGENT"});}, "is_optional": " "}}},
  "CREATE_PULL_REQUEST": {"visibility": "U", "parameters": {"IV_TITLE": {"type": () => {return new abap.types.Character();}, "is_optional": " "}, "IV_BODY": {"type": () => {return new abap.types.Character();}, "is_optional": " "}, "IV_HEAD": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "IV_BASE": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}},
  "UPDATE_PULL_REQUEST_BRANCH": {"visibility": "U", "parameters": {"IV_PULL_NUMBER": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "is_optional": " "}, "IV_EXPECTED_HEAD_SHA": {"type": () => {return new abap.types.Character(40, {"qualifiedName":"zif_abapgit_git_definitions=>ty_sha1"});}, "is_optional": " "}}},
  "READY_FOR_REVIEW": {"visibility": "U", "parameters": {"IV_PULL_NUMBER": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "is_optional": " "}}}};
  #mi_http_agent;
  #mv_repo_url;
  #mv_user_and_repo;
  constructor() {
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
      "fetch_repo_by_url": this.#fetch_repo_by_url.bind(this),
      "convert_list": this.#convert_list.bind(this),
      "clean_url": this.#clean_url.bind(this),
      "create_pull_request": this.create_pull_request.bind(this),
      "update_pull_request_branch": this.update_pull_request_branch.bind(this),
      "ready_for_review": this.ready_for_review.bind(this),
    };
    this.#mi_http_agent = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_HTTP_AGENT", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_HTTP_AGENT"});
    this.FRIENDS_ACCESS_INSTANCE["mi_http_agent"] = this.#mi_http_agent;
    this.#mv_repo_url = new abap.types.String({qualifiedName: "STRING"});
    this.FRIENDS_ACCESS_INSTANCE["mv_repo_url"] = this.#mv_repo_url;
    this.#mv_user_and_repo = new abap.types.String({qualifiedName: "STRING"});
    this.FRIENDS_ACCESS_INSTANCE["mv_user_and_repo"] = this.#mv_user_and_repo;
  }
  async constructor_(INPUT) {
    let iv_user_and_repo = INPUT?.iv_user_and_repo;
    if (iv_user_and_repo?.getQualifiedName === undefined || iv_user_and_repo.getQualifiedName() !== "STRING") { iv_user_and_repo = undefined; }
    if (iv_user_and_repo === undefined) { iv_user_and_repo = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_user_and_repo); }
    let ii_http_agent = INPUT?.ii_http_agent;
    if (ii_http_agent?.getQualifiedName === undefined || ii_http_agent.getQualifiedName() !== "ZIF_ABAPGIT_HTTP_AGENT") { ii_http_agent = undefined; }
    if (ii_http_agent === undefined) { ii_http_agent = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_HTTP_AGENT", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_HTTP_AGENT"}).set(INPUT.ii_http_agent); }
    let lv_search = new abap.types.String({qualifiedName: "STRING"});
    this.#mv_user_and_repo.set(iv_user_and_repo);
    this.#mv_repo_url.set(new abap.types.String().set(`https://api.github.com/repos/${abap.templateFormatting(iv_user_and_repo)}`));
    this.#mi_http_agent.set(ii_http_agent);
    await (await this.#mi_http_agent.get().zif_abapgit_http_agent$global_headers()).get().set({iv_key: abap.CharacterFactory.get(6, 'Accept'), iv_val: abap.CharacterFactory.get(30, 'application/vnd.github.v3+json')});
    if (abap.compare.initial((await abap.Classes['ZCL_ABAPGIT_LOGIN_MANAGER'].get({iv_uri: this.#mv_repo_url}))) === false) {
      await (await this.#mi_http_agent.get().zif_abapgit_http_agent$global_headers()).get().set({iv_key: abap.CharacterFactory.get(13, 'Authorization'), iv_val: (await abap.Classes['ZCL_ABAPGIT_LOGIN_MANAGER'].get({iv_uri: this.#mv_repo_url}))});
    } else {
      lv_search.set(this.#mv_repo_url);
      abap.statements.replace({target: lv_search, all: false, with: abap.CharacterFactory.get(10, 'github.com'), of: abap.CharacterFactory.get(20, 'api.github.com/repos')});
      if (abap.compare.initial((await abap.Classes['ZCL_ABAPGIT_LOGIN_MANAGER'].get({iv_uri: lv_search}))) === false) {
        await (await this.#mi_http_agent.get().zif_abapgit_http_agent$global_headers()).get().set({iv_key: abap.CharacterFactory.get(13, 'Authorization'), iv_val: (await abap.Classes['ZCL_ABAPGIT_LOGIN_MANAGER'].get({iv_uri: lv_search}))});
      }
    }
    return this;
  }
  async #convert_list(INPUT) {
    let rt_pulls = abap.types.TableFactory.construct(new abap.types.Structure({
    "base_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-BASE_URL"}),
    "number": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-NUMBER"}),
    "title": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-TITLE"}),
    "user": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-USER"}),
    "head_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HEAD_URL"}),
    "head_branch": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HEAD_BRANCH"}),
    "created_at": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-CREATED_AT"}),
    "is_for_upstream": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}),
    "draft": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}),
    "html_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HTML_URL"})}, "zif_abapgit_pr_enum_provider=>ty_pull_request", undefined, {}, {}), {"withHeader":false,"keyType":"USER","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":["BASE_URL","NUMBER"]},"secondary":[]}, "zif_abapgit_pr_enum_provider=>ty_pull_requests");
    let ii_json = INPUT?.ii_json;
    if (ii_json?.getQualifiedName === undefined || ii_json.getQualifiedName() !== "ZIF_ABAPGIT_AJSON") { ii_json = undefined; }
    if (ii_json === undefined) { ii_json = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_AJSON", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_AJSON"}).set(INPUT.ii_json); }
    let lt_items = abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE");
    let lv_i = new abap.types.String({qualifiedName: "STRING"});
    let fs_ls_p_ = new abap.types.FieldSymbol(new abap.types.Structure({
    "base_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-BASE_URL"}),
    "number": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-NUMBER"}),
    "title": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-TITLE"}),
    "user": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-USER"}),
    "head_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HEAD_URL"}),
    "head_branch": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HEAD_BRANCH"}),
    "created_at": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-CREATED_AT"}),
    "is_for_upstream": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}),
    "draft": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}),
    "html_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HTML_URL"})}, "zif_abapgit_pr_enum_provider=>ty_pull_request", undefined, {}, {}));
    lt_items.set((await ii_json.get().zif_abapgit_ajson$members({iv_path: abap.CharacterFactory.get(1, '/')})));
    for await (const unique233 of abap.statements.loop(lt_items)) {
      lv_i.set(unique233);
      fs_ls_p_.assign(rt_pulls.appendInitial());
      fs_ls_p_.get().base_url.set((await ii_json.get().zif_abapgit_ajson$get({iv_path: new abap.types.String().set(`/${abap.templateFormatting(lv_i)}/base/repo/clone_url`)})));
      fs_ls_p_.get().number.set((await ii_json.get().zif_abapgit_ajson$get({iv_path: new abap.types.String().set(`/${abap.templateFormatting(lv_i)}/number`)})));
      fs_ls_p_.get().title.set((await ii_json.get().zif_abapgit_ajson$get({iv_path: new abap.types.String().set(`/${abap.templateFormatting(lv_i)}/title`)})));
      fs_ls_p_.get().user.set((await ii_json.get().zif_abapgit_ajson$get({iv_path: new abap.types.String().set(`/${abap.templateFormatting(lv_i)}/user/login`)})));
      fs_ls_p_.get().head_url.set((await ii_json.get().zif_abapgit_ajson$get({iv_path: new abap.types.String().set(`/${abap.templateFormatting(lv_i)}/head/repo/clone_url`)})));
      fs_ls_p_.get().head_branch.set((await ii_json.get().zif_abapgit_ajson$get({iv_path: new abap.types.String().set(`/${abap.templateFormatting(lv_i)}/head/ref`)})));
      fs_ls_p_.get().created_at.set((await ii_json.get().zif_abapgit_ajson$get({iv_path: new abap.types.String().set(`/${abap.templateFormatting(lv_i)}/created_at`)})));
      fs_ls_p_.get().draft.set((await ii_json.get().zif_abapgit_ajson$get_boolean({iv_path: new abap.types.String().set(`/${abap.templateFormatting(lv_i)}/draft`)})));
      fs_ls_p_.get().html_url.set((await ii_json.get().zif_abapgit_ajson$get({iv_path: new abap.types.String().set(`/${abap.templateFormatting(lv_i)}/html_url`)})));
    }
    return rt_pulls;
  }
  async #fetch_repo_by_url(INPUT) {
    let rs_info = new abap.types.Structure({
    "repo_json": new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_AJSON", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_AJSON"}),
    "pulls": abap.types.TableFactory.construct(new abap.types.Structure({
    "base_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-BASE_URL"}),
    "number": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-NUMBER"}),
    "title": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-TITLE"}),
    "user": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-USER"}),
    "head_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HEAD_URL"}),
    "head_branch": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HEAD_BRANCH"}),
    "created_at": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-CREATED_AT"}),
    "is_for_upstream": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}),
    "draft": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}),
    "html_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HTML_URL"})}, "zif_abapgit_pr_enum_provider=>ty_pull_request", undefined, {}, {}), {"withHeader":false,"keyType":"USER","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":["BASE_URL","NUMBER"]},"secondary":[]}, "zif_abapgit_pr_enum_provider=>ty_pull_requests")}, "zcl_abapgit_pr_enum_github=>ty_info", undefined, {}, {});
    let iv_repo_url = INPUT?.iv_repo_url;
    if (iv_repo_url?.getQualifiedName === undefined || iv_repo_url.getQualifiedName() !== "STRING") { iv_repo_url = undefined; }
    if (iv_repo_url === undefined) { iv_repo_url = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_repo_url); }
    let li_pulls_json = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_AJSON", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_AJSON"});
    let lv_pull_url = new abap.types.String({qualifiedName: "STRING"});
    let li_response = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_HTTP_RESPONSE", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_HTTP_RESPONSE"});
    let lx_ajson = new abap.types.ABAPObject({qualifiedName: "ZCX_ABAPGIT_AJSON_ERROR", RTTIName: "\\CLASS=ZCX_ABAPGIT_AJSON_ERROR"});
    li_response.set((await this.#mi_http_agent.get().zif_abapgit_http_agent$request({iv_url: iv_repo_url})));
    try {
      rs_info.get().repo_json.set((await li_response.get().zif_abapgit_http_response$json()));
      await li_response.get().zif_abapgit_http_response$headers();
      lv_pull_url.set((await this.#clean_url({iv_url: (await rs_info.get().repo_json.get().zif_abapgit_ajson$get({iv_path: abap.CharacterFactory.get(10, '/pulls_url')}))})));
      if (abap.compare.initial(lv_pull_url) || abap.compare.eq((await rs_info.get().repo_json.get().zif_abapgit_ajson$get({iv_path: abap.CharacterFactory.get(8, '/message')})), abap.CharacterFactory.get(9, 'Not Found'))) {
        return rs_info;
      }
      li_pulls_json.set((await (await this.#mi_http_agent.get().zif_abapgit_http_agent$request({iv_url: lv_pull_url})).get().zif_abapgit_http_response$json()));
    } catch (e) {
      if ((abap.Classes['ZCX_ABAPGIT_AJSON_ERROR'] && e instanceof abap.Classes['ZCX_ABAPGIT_AJSON_ERROR'])) {
        lx_ajson.set(e);
        await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise_with_text({ix_previous: lx_ajson});
      } else {
        throw e;
      }
    }
    rs_info.get().pulls.set((await this.#convert_list({ii_json: li_pulls_json})));
    return rs_info;
  }
  async zif_abapgit_pr_enum_provider$list_pull_requests() {
    let rt_pulls = abap.types.TableFactory.construct(new abap.types.Structure({
    "base_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-BASE_URL"}),
    "number": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-NUMBER"}),
    "title": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-TITLE"}),
    "user": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-USER"}),
    "head_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HEAD_URL"}),
    "head_branch": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HEAD_BRANCH"}),
    "created_at": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-CREATED_AT"}),
    "is_for_upstream": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}),
    "draft": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}),
    "html_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HTML_URL"})}, "zif_abapgit_pr_enum_provider=>ty_pull_request", undefined, {}, {}), {"withHeader":false,"keyType":"USER","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":["BASE_URL","NUMBER"]},"secondary":[]}, "zif_abapgit_pr_enum_provider=>ty_pull_requests");
    let lv_upstream_url = new abap.types.String({qualifiedName: "STRING"});
    let ls_repo_info = new abap.types.Structure({
    "repo_json": new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_AJSON", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_AJSON"}),
    "pulls": abap.types.TableFactory.construct(new abap.types.Structure({
    "base_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-BASE_URL"}),
    "number": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-NUMBER"}),
    "title": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-TITLE"}),
    "user": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-USER"}),
    "head_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HEAD_URL"}),
    "head_branch": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HEAD_BRANCH"}),
    "created_at": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-CREATED_AT"}),
    "is_for_upstream": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}),
    "draft": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}),
    "html_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HTML_URL"})}, "zif_abapgit_pr_enum_provider=>ty_pull_request", undefined, {}, {}), {"withHeader":false,"keyType":"USER","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":["BASE_URL","NUMBER"]},"secondary":[]}, "zif_abapgit_pr_enum_provider=>ty_pull_requests")}, "zcl_abapgit_pr_enum_github=>ty_info", undefined, {}, {});
    let fs_ls_p_ = new abap.types.FieldSymbol(new abap.types.Structure({
    "base_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-BASE_URL"}),
    "number": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-NUMBER"}),
    "title": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-TITLE"}),
    "user": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-USER"}),
    "head_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HEAD_URL"}),
    "head_branch": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HEAD_BRANCH"}),
    "created_at": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-CREATED_AT"}),
    "is_for_upstream": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}),
    "draft": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}),
    "html_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HTML_URL"})}, "zif_abapgit_pr_enum_provider=>ty_pull_request", undefined, {}, {}));
    ls_repo_info.set((await this.#fetch_repo_by_url({iv_repo_url: this.#mv_repo_url})));
    abap.statements.append({source: ls_repo_info.get().pulls, lines: true, target: rt_pulls});
    if (abap.compare.eq((await ls_repo_info.get().repo_json.get().zif_abapgit_ajson$get_boolean({iv_path: abap.CharacterFactory.get(5, '/fork')})), abap.builtin.abap_true)) {
      lv_upstream_url.set((await ls_repo_info.get().repo_json.get().zif_abapgit_ajson$get({iv_path: abap.CharacterFactory.get(11, '/source/url')})));
      ls_repo_info.set((await this.#fetch_repo_by_url({iv_repo_url: lv_upstream_url})));
      for await (const unique234 of abap.statements.loop(ls_repo_info.get().pulls)) {
        fs_ls_p_.assign(unique234);
        fs_ls_p_.get().is_for_upstream.set(abap.builtin.abap_true);
        abap.statements.append({source: fs_ls_p_, target: rt_pulls});
      }
    }
    return rt_pulls;
  }
  async create_pull_request(INPUT) {
    let iv_title = INPUT?.iv_title;
    let iv_body = INPUT?.iv_body || new abap.types.Character();
    let iv_head = INPUT?.iv_head;
    if (iv_head?.getQualifiedName === undefined || iv_head.getQualifiedName() !== "STRING") { iv_head = undefined; }
    if (iv_head === undefined) { iv_head = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_head); }
    let iv_base = new abap.types.String({qualifiedName: "STRING"});
    if (INPUT && INPUT.iv_base) {iv_base.set(INPUT.iv_base);}
    if (INPUT === undefined || INPUT.iv_base === undefined) {iv_base = abap.CharacterFactory.get(4, 'main');}
    let lv_owner = new abap.types.String({qualifiedName: "STRING"});
    let lv_repo = new abap.types.String({qualifiedName: "STRING"});
    let lv_url = new abap.types.String({qualifiedName: "STRING"});
    let lv_json = new abap.types.String({qualifiedName: "STRING"});
    let li_response = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_HTTP_RESPONSE", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_HTTP_RESPONSE"});
    lv_url.set(abap.operators.concat(this.#mv_repo_url,abap.CharacterFactory.get(6, '/pulls')));
    abap.statements.split({source: this.#mv_user_and_repo, at: abap.CharacterFactory.get(1, '/'), targets: [lv_owner,lv_repo]});
    lv_json.set(abap.operators.concat(new abap.types.String().set(`\{\n`),abap.operators.concat(new abap.types.String().set(`  "owner": "${abap.templateFormatting(lv_owner)}",\n`),abap.operators.concat(new abap.types.String().set(`  "repo": "${abap.templateFormatting(lv_repo)}",\n`),abap.operators.concat(new abap.types.String().set(`  "title": "${abap.templateFormatting(iv_title)}",\n`),abap.operators.concat(new abap.types.String().set(`  "head": "${abap.templateFormatting(iv_head)}",\n`),abap.operators.concat(new abap.types.String().set(`  "body": "${abap.templateFormatting(iv_body)}",\n`),abap.operators.concat(new abap.types.String().set(`  "maintainer_can_modify": true,\n`),abap.operators.concat(new abap.types.String().set(`  "draft": true,\n`),abap.operators.concat(new abap.types.String().set(`  "base": "${abap.templateFormatting(iv_base)}"\n`),new abap.types.String().set(`\}`)))))))))));
    li_response.set((await this.#mi_http_agent.get().zif_abapgit_http_agent$request({iv_url: lv_url, iv_method: abap.Classes['ZIF_ABAPGIT_HTTP_AGENT'].zif_abapgit_http_agent$c_methods.get().post, iv_payload: lv_json})));
    if (abap.compare.eq((await li_response.get().zif_abapgit_http_response$is_ok()), abap.builtin.abap_false)) {
      await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise({iv_text: new abap.types.String().set(`Error creating pull request: ${abap.templateFormatting((await li_response.get().zif_abapgit_http_response$error()))}`)});
    }
  }
  async ready_for_review(INPUT) {
    let iv_pull_number = INPUT?.iv_pull_number;
    if (iv_pull_number?.getQualifiedName === undefined || iv_pull_number.getQualifiedName() !== "I") { iv_pull_number = undefined; }
    if (iv_pull_number === undefined) { iv_pull_number = new abap.types.Integer({qualifiedName: "I"}).set(INPUT.iv_pull_number); }
    let lv_url = new abap.types.String({qualifiedName: "STRING"});
    let lv_json = new abap.types.String({qualifiedName: "STRING"});
    let li_response = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_HTTP_RESPONSE", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_HTTP_RESPONSE"});
    let lx_ajson = new abap.types.ABAPObject({qualifiedName: "ZCX_ABAPGIT_AJSON_ERROR", RTTIName: "\\CLASS=ZCX_ABAPGIT_AJSON_ERROR"});
    let lv_node_id = new abap.types.String({qualifiedName: "STRING"});
    lv_url.set(abap.operators.concat(this.#mv_repo_url,abap.operators.concat(abap.CharacterFactory.get(7, '/pulls/'),iv_pull_number)));
    li_response.set((await this.#mi_http_agent.get().zif_abapgit_http_agent$request({iv_url: lv_url, iv_method: abap.Classes['ZIF_ABAPGIT_HTTP_AGENT'].zif_abapgit_http_agent$c_methods.get().get})));
    if (abap.compare.eq((await li_response.get().zif_abapgit_http_response$is_ok()), abap.builtin.abap_false)) {
      await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise({iv_text: new abap.types.String().set(`Error getting pull request information: ${abap.templateFormatting((await li_response.get().zif_abapgit_http_response$error()))}`)});
    }
    try {
      lv_node_id.set((await (await li_response.get().zif_abapgit_http_response$json()).get().zif_abapgit_ajson$get({iv_path: new abap.types.String().set(`/node_id`)})));
    } catch (e) {
      if ((abap.Classes['ZCX_ABAPGIT_AJSON_ERROR'] && e instanceof abap.Classes['ZCX_ABAPGIT_AJSON_ERROR'])) {
        lx_ajson.set(e);
        await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise_with_text({ix_previous: lx_ajson});
      } else {
        throw e;
      }
    }
    lv_json.set(abap.operators.concat(new abap.types.String().set(`\{"query": "mutation \{ markPullRequestReadyForReview(input: `),new abap.types.String().set(`\{ pullRequestId: \\"${abap.templateFormatting(lv_node_id)}\\" \}) \{ pullRequest \{ id \} \} \}" \}`)));
    li_response.set((await this.#mi_http_agent.get().zif_abapgit_http_agent$request({iv_url: abap.CharacterFactory.get(30, 'https://api.github.com/graphql'), iv_method: abap.Classes['ZIF_ABAPGIT_HTTP_AGENT'].zif_abapgit_http_agent$c_methods.get().post, iv_payload: lv_json})));
    if (abap.compare.eq((await li_response.get().zif_abapgit_http_response$is_ok()), abap.builtin.abap_false)) {
      await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise({iv_text: new abap.types.String().set(`Error setting to ready: ${abap.templateFormatting((await li_response.get().zif_abapgit_http_response$error()))}`)});
    }
  }
  async update_pull_request_branch(INPUT) {
    let iv_pull_number = INPUT?.iv_pull_number;
    if (iv_pull_number?.getQualifiedName === undefined || iv_pull_number.getQualifiedName() !== "I") { iv_pull_number = undefined; }
    if (iv_pull_number === undefined) { iv_pull_number = new abap.types.Integer({qualifiedName: "I"}).set(INPUT.iv_pull_number); }
    let iv_expected_head_sha = INPUT?.iv_expected_head_sha;
    if (iv_expected_head_sha?.getQualifiedName === undefined || iv_expected_head_sha.getQualifiedName() !== "ZIF_ABAPGIT_GIT_DEFINITIONS=>TY_SHA1") { iv_expected_head_sha = undefined; }
    if (iv_expected_head_sha === undefined) { iv_expected_head_sha = new abap.types.Character(40, {"qualifiedName":"zif_abapgit_git_definitions=>ty_sha1"}).set(INPUT.iv_expected_head_sha); }
    let lv_owner = new abap.types.String({qualifiedName: "STRING"});
    let lv_repo = new abap.types.String({qualifiedName: "STRING"});
    let lv_url = new abap.types.String({qualifiedName: "STRING"});
    let lv_json = new abap.types.String({qualifiedName: "STRING"});
    let li_response = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_HTTP_RESPONSE", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_HTTP_RESPONSE"});
    lv_url.set(abap.operators.concat(this.#mv_repo_url,abap.operators.concat(abap.CharacterFactory.get(7, '/pulls/'),abap.operators.concat(iv_pull_number,abap.CharacterFactory.get(14, '/update-branch')))));
    abap.statements.split({source: this.#mv_user_and_repo, at: abap.CharacterFactory.get(1, '/'), targets: [lv_owner,lv_repo]});
    lv_json.set(abap.operators.concat(new abap.types.String().set(`\{\n`),abap.operators.concat(new abap.types.String().set(`  "expected_head_sha": "${abap.templateFormatting(abap.builtin.to_lower({val: iv_expected_head_sha}))}"\n`),new abap.types.String().set(`\}`))));
    li_response.set((await this.#mi_http_agent.get().zif_abapgit_http_agent$request({iv_url: lv_url, iv_method: abap.Classes['ZIF_ABAPGIT_HTTP_AGENT'].zif_abapgit_http_agent$c_methods.get().put, iv_payload: lv_json})));
    if (abap.compare.eq((await li_response.get().zif_abapgit_http_response$is_ok()), abap.builtin.abap_false)) {
      await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise({iv_text: new abap.types.String().set(`Error updating pull request branch: ${abap.templateFormatting((await li_response.get().zif_abapgit_http_response$error()))}`)});
    }
  }
  async #clean_url(INPUT) {
    let rv_url = new abap.types.String({qualifiedName: "STRING"});
    let iv_url = INPUT?.iv_url;
    if (iv_url?.getQualifiedName === undefined || iv_url.getQualifiedName() !== "STRING") { iv_url = undefined; }
    if (iv_url === undefined) { iv_url = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_url); }
    rv_url.set(abap.builtin.replace({val: iv_url, regex: abap.CharacterFactory.get(7, '\\{.*\\}$'), with: abap.CharacterFactory.get(1, '')}));
    return rv_url;
  }
}
abap.Classes['ZCL_ABAPGIT_PR_ENUM_GITHUB'] = zcl_abapgit_pr_enum_github;
zcl_abapgit_pr_enum_github.ty_info = new abap.types.Structure({
"repo_json": new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_AJSON", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_AJSON"}),
"pulls": abap.types.TableFactory.construct(new abap.types.Structure({
"base_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-BASE_URL"}),
"number": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-NUMBER"}),
"title": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-TITLE"}),
"user": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-USER"}),
"head_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HEAD_URL"}),
"head_branch": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HEAD_BRANCH"}),
"created_at": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-CREATED_AT"}),
"is_for_upstream": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}),
"draft": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}),
"html_url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_PR_ENUM_PROVIDER=>TY_PULL_REQUEST-HTML_URL"})}, "zif_abapgit_pr_enum_provider=>ty_pull_request", undefined, {}, {}), {"withHeader":false,"keyType":"USER","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":["BASE_URL","NUMBER"]},"secondary":[]}, "zif_abapgit_pr_enum_provider=>ty_pull_requests")}, "zcl_abapgit_pr_enum_github=>ty_info", undefined, {}, {});
export {zcl_abapgit_pr_enum_github};