package com.yidian.bcommon.http

import com.yidian.bcommon.http.bean.CommitFeedbackBean
import com.yidian.bcommon.http.bean.GetCommonConfigBean
import io.reactivex.rxjava3.core.Observable
import retrofit2.Call
import retrofit2.http.*

/**
 * author: yinjiacheng
 * date: 7/8/21 4:53 PM
 * description: Common网络请求定义
 */
interface CommonService {

  companion object {
    const val SCHEME_HTTP = "http://"
    const val SCHEME_HTTPS = "https://"

    // Tower Api域名定义
    const val DOMAIN_TOWER_API_TEST = "open-tower-api.test.int.yidian-inc.com:8222"
    const val DOMAIN_TOWER_API_PRO = "open-tower-api.go2yd.com"

    // 一点jira域名定义
    const val DOMAIN_YD_JIRA = "ydjira.yidian-inc.com"

    // tower-api 获取配置数据
    private const val getCommonConfig = "/api/resource"

    // 用户反馈提交
    private const val commitFeedback = "/rest/api/2/issue"
  }

  @Headers("Content-Type: application/json")
  @POST(URLs.getKSYunToken)
  fun getKSYunToken(@QueryMap commonParams: Map<String, String>, @Body requestParams: Map<String, String?>): Call<HttpResult<Any?>>

  @GET(URLs.getKSYunObjectId)
  fun getKSYunObjectId(
    @QueryMap commonParams: Map<String, String>,
    @QueryMap requestParams: Map<String, String?>
  ): Observable<HttpResult<Any?>>

  @GET(getCommonConfig)
  fun getCommonConfig(@QueryMap requestParams: Map<String, String>): Observable<HttpResult<GetCommonConfigBean.GetCommonConfigResponse>>

  @Headers("Content-Type: application/json", "Authorization: Basic Y2xpZW50LXVwbG9hZDpUZXN0MTIzNCU=")
  @POST(commitFeedback)
  fun commitFeedback(@Body requestParams: CommitFeedbackBean.CommitFeedbackRequest): Observable<HttpResult<CommitFeedbackBean.CommitFeedbackResponse>>
}
