pub mod assignee;
pub mod comment;
pub mod label;
pub mod merge;
pub mod pull_request;
pub mod reaction;
pub mod review;

use actix_web::{web, web::ServiceConfig};

pub fn configure(cfg: &mut ServiceConfig) {
    cfg.service(
        web::scope("/{repo}/pull-requests")
            .service(
                web::resource("")
                    .route(web::get().to(pull_request::list_prs))
                    .route(web::post().to(pull_request::create_pr)),
            )
            .service(
                web::resource("/{number}")
                    .route(web::get().to(pull_request::get_pr))
                    .route(web::patch().to(pull_request::update_pr))
                    .route(web::delete().to(pull_request::delete_pr)),
            )
            .service(
                web::resource("/{number}/merge")
                    .route(web::get().to(merge::merge_analysis))
                    .route(web::post().to(merge::merge_pr)),
            )
            .service(
                web::resource("/{number}/update-branch")
                    .route(web::post().to(merge::update_branch)),
            )
            .service(
                web::resource("/{number}/assignees")
                    .route(web::post().to(assignee::assign_user))
                    .route(web::delete().to(assignee::unassign_user)),
            )
            .service(
                web::resource("/{number}/comments")
                    .route(web::get().to(comment::list_comments))
                    .route(web::post().to(comment::create_comment)),
            )
            .service(
                web::resource("/{number}/comments/{comment_id}")
                    .route(web::put().to(comment::update_comment))
                    .route(web::delete().to(comment::delete_comment)),
            )
            .service(
                web::resource("/{number}/labels")
                    .route(web::post().to(label::add_label))
                    .route(web::delete().to(label::remove_label)),
            )
            .service(
                web::resource("/{number}/reviews")
                    .route(web::get().to(review::list_reviews))
                    .route(web::post().to(review::create_review)),
            )
            .service(
                web::resource("/{number}/reviews/{review_id}/dismiss")
                    .route(web::post().to(review::dismiss_review)),
            )
            .service(
                web::resource("/{number}/review-comments")
                    .route(web::post().to(review::create_review_comment)),
            )
            .service(
                web::resource("/{number}/reactions")
                    .route(web::post().to(reaction::add_reaction))
                    .route(web::delete().to(reaction::remove_reaction)),
            )
            .service(
                web::resource("/{number}/comments/{comment_id}/reactions")
                    .route(web::post().to(reaction::add_comment_reaction))
                    .route(web::delete().to(reaction::remove_comment_reaction)),
            ),
    );
}
