All Downloads are FREE. Search and download functionalities are using the official Maven repository.

notion.api.v1.endpoint.EndpointsSupport.kt Maven / Gradle / Ivy

package notion.api.v1.endpoint

import java.net.URLEncoder
import notion.api.v1.http.UserAgent

interface EndpointsSupport {
  val token: String?

  fun buildRequestHeaders(additionalOnes: Map): Map {
    val commonHeaders =
        mapOf(
                "Authorization" to "Bearer $token",
                "Notion-Version" to "2022-02-22",
                "User-Agent" to UserAgent.buildUserAgent(),
            )
            .plus(additionalOnes)

    return if (token != null) {
      commonHeaders.plus("Authorization" to "Bearer $token")
    } else {
      commonHeaders
    }
  }

  fun urlEncode(value: String): String = URLEncoder.encode(value, "UTF-8")

  fun contentTypeJson(): Map =
      mapOf("Content-Type" to "application/json; charset=utf-8")
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy