This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.github.doyaaaaaken.kotlincsv.dsl.csvReader | |
import io.blackmo18.kotlin.grass.dsl.grass | |
val csv = """ | |
firstName,lastName,email | |
John,Doe,[email protected] | |
""".trimIndent() | |
data class Contact( | |
val firstName: String?, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Bean | |
fun webClient(authorizedClientManager: OAuth2AuthorizedClientManager): WebClient = | |
WebClient | |
.builder() | |
.apply( | |
ServletOAuth2AuthorizedClientExchangeFilterFunction( | |
authorizedClientManager | |
).oauth2Configuration() | |
) | |
.build() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client | |
// ... | |
.attributes( | |
ServerOAuth2AuthorizedClientExchangeFilterFunction | |
.oauth2AuthorizedClient( | |
authorizedClientService.loadAuthorizedClient("hubspot", event["portalId"]) | |
) | |
) | |
.retrieve() | |
.bodyToMono<String>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
// ... | |
implementation("org.springframework.boot:spring-boot-starter-jdbc") | |
implementation("org.flywaydb:flyway-core") // Optional, but highly recommended | |
implementation("org.postgresql:postgresql") // Add the driver for your favourite database here | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
class WebhooksController { | |
// ... | |
@Autowired | |
private lateinit var authorizedClientService: OAuth2AuthorizedClientService | |
@PostMapping("/webhooks/hubspot") | |
fun hubspot(@RequestBody events: List<Map<String, String>>) { | |
events |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
class WebhooksController { | |
@Autowired | |
private lateinit var client: WebClient | |
@PostMapping("/webhooks/hubspot") | |
fun hubspot(@RequestBody events: List<Map<String, String>>) { | |
events | |
.map { event -> | |
client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
// ... | |
implementation("org.springframework.boot:spring-boot-starter-webflux") | |
// ... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Bean | |
fun oauth2Configuration(http: HttpSecurity): SecurityFilterChain = | |
http | |
.oauth2Client() | |
// ... | |
.and().and() | |
.csrf().disable() | |
.build() |
NewerOlder