Skip to content

boomeventsorg/hubspot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

28 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– HubSpot Kotlin SDK

General implementation of HubSpot CRM API in tiny Kotlin SDK.

🎈 Currently in progress, send issues or pull requests πŸ™ŒπŸΌ

πŸš€ Install from official Maven repository with org.boomevents:hubspot-sdk:$VERSION

Supported features

Feature List Read Create Change Delete
Company ❌ βœ… βœ… βœ… βœ…
Custom objects ❌ βœ… βœ… βœ… βœ…
Deal ❌ βœ… βœ… βœ… βœ…
Contact ❌ βœ… βœ… βœ… βœ…
Associations ❌ ❌ βœ… ❌ ❌

Supported types

Type Note Supported
String - βœ…
Boolean - βœ…
Long - βœ…
Int - βœ…
Enum Use Java String converted ❌
Date Use Java 8 dates with toString formatter ❌

Usage Examples

Basic SDK client configuration

// All basic types are supported
class MyCustomCompanyProperties(
    val name: String,
    val age: Int,
    val email: String,
    val newsletter: Boolean,

    // You can customize final property name send to HubSpot API
    @JsonProperty("billing_bank_iban")
    val iban: String? = null
)

val client = Client(
    apiBasePath = "https://api.hubapi.com",

    // Found in HubSpot company management -> Integrations -> API Keys -> Active API Key
    apiKey = "xxx"
)

#️⃣ Company entity

Create brand-new company

val companyRequest = CompanyRequest(
    properties = MyCustomCompanyProperties(
        name = "John Doe",
        age = 34,
        email = "john.doe@example.com",
        newsletter = true
    )
)

val companyResponse = companiesClient.createCompany(companyRequest)

println(companyResponse.id) // HubSpot company ID
println(companyResponse.properties["name"]) // John Doe

Change existing company

val companyRequest = CompanyRequest(
    properties = MyCustomCompanyProperties(
        name = "John Doe",
        age = 34,
        email = "john.doe@example.com",
        newsletter = true
    )
)

val companyResponse = companiesClient.changeCompany(123456789, companyRequest)

println(companyResponse.id) // HubSpot company ID
println(companyResponse.properties["name"]) // John Doe

#️⃣ Custom objects

Create brand-new custom object record

val request = CustomObjectRequest(
    properties = MySuperEventProperties(
        name = "Party #2022",
        address = "New York",

        // Date must be formatted as "YYYY-MM-DD"
        dateFrom = LocalDate
            .now()
            .plusDays(10)
            .format(DateTimeFormatter.ISO_LOCAL_DATE),
        dateUntil = LocalDate
            .now()
            .plusDays(15)
            .format(DateTimeFormatter.ISO_LOCAL_DATE),
    )
)

// HubSpot client and name of custom object table
val myEventsClient = CustomObjectClient(client, "events")

val response = myEventsClient.createCustomObjectRecord(request)

println(response.id) // HubSpot ID
println(response.properties["name"]) // Party #2022

Associate a contact to an existing company with default label

val associationClient = AssociationClient(hubspotClient)

val associationRequest = AssociationRequest(
    fromObjectType = CONTACT, // contact, company, deal, etc
    fromObjectId = 1, // HubSpot ID of the contact
    toObjectType = COMPANY, // contact, company, deal, etc
    toObjectId = 2 // HubSpot ID of the company
)

val associationResponse = associationClient.createDefaultAssociation(associationRequest)

println(associationResponse.id)