Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stefanozanella/63389941b3485f6a829492a6447b6797 to your computer and use it in GitHub Desktop.
Save stefanozanella/63389941b3485f6a829492a6447b6797 to your computer and use it in GitHub Desktop.
@RestController
class WebhooksController {
@Autowired
private lateinit var client: WebClient
@PostMapping("/webhooks/hubspot")
fun hubspot(@RequestBody events: List<Map<String, String>>) {
events
.map { event ->
client
.get()
.uri("https://api.hubapi.com/crm/v3/objects/deals/{objectId}") { uri ->
uri
.queryParam("properties", "hubspot_owner_id,hs_arr,amount,dealstage")
.build(event["objectId"])
}
.retrieve()
.bodyToMono<String>()
.block()
}
.forEach(::println)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment