Skip to content

Instantly share code, notes, and snippets.

@larshp
Created October 12, 2023 06:27

Revisions

  1. larshp created this gist Oct 12, 2023.
    30 changes: 30 additions & 0 deletions abapgit_exit_wall_topics.abap
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    METHOD zif_abapgit_exit~wall_message_repo.

    DATA(lv_url) = is_repo_meta-url.

    DATA(lo_agent) = zcl_abapgit_factory=>get_http_agent( ).

    IF zcl_abapgit_login_manager=>get( lv_url ) IS NOT INITIAL.
    lo_agent->global_headers( )->set(
    iv_key = 'Authorization'
    iv_val = zcl_abapgit_login_manager=>get( lv_url ) ).
    ENDIF.

    lv_url = replace(
    val = is_repo_meta-url
    sub = 'github.com'
    with = 'api.github.com/repos' ).
    lv_url = lv_url && '/topics'.

    lo_agent->global_headers( )->set(
    iv_key = 'Accept'
    iv_val = 'application/vnd.github+json' ).

    DATA(li_json) = lo_agent->request( lv_url )->json( ).
    DATA(lt_topics) = li_json->array_to_string_table( '/names/' ).
    READ TABLE lt_topics WITH KEY table_line = |sap-{ to_lower( sy-sysid ) }| TRANSPORTING NO FIELDS.
    IF sy-subrc <> 0.
    ii_html->add( |<div class="form-container">Please add topic "sap-{ to_lower( sy-sysid ) }" to the repository on github</div>| ).
    ENDIF.

    ENDMETHOD.