-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Task CRUD * feat: add support for querying specific properties in findCompany - Updated the findCompany method to accept an optional list of properties. - Constructed the URL to append these properties as query parameters. - This allows users to specify which fields to retrieve for a company
- Loading branch information
1 parent
20fd19e
commit 35d7ec8
Showing
22 changed files
with
294 additions
and
80 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
# 🤖 HubSpot Kotlin SDK | ||
|
||
General implementation of [HubSpot](https://developers.hubspot.com/docs/api/crm/companies) 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`<br> | ||
|
||
## Supported features | ||
| Feature | List | Read | Create | Change | Delete | | ||
|------------------|--------|--------|----------|----------|----------| | ||
| Company | ❌ | ✅ | ✅ | ✅ | ✅ | | ||
| Custom objects | ❌ | ✅ | ✅ | ✅ | ✅ | | ||
| Deal | ❌ | ✅ | ✅ | ✅ | ✅ | | ||
| Contact | ❌ | ✅ | ✅ | ✅ | ✅ | | ||
| Associations | ❌ | ❌ | ✅ | ❌ | ❌ | | ||
|
||
| Feature | List | Read | Create | Change | Delete | | ||
|----------------|--------|--------|----------|----------|----------| | ||
| Company | ❌ | ✅ | ✅ | ✅ | ✅ | | ||
| Custom objects | ❌ | ✅ | ✅ | ✅ | ✅ | | ||
| Deal | ❌ | ✅ | ✅ | ✅ | ✅ | | ||
| Contact | ❌ | ✅ | ✅ | ✅ | ✅ | | ||
| Associations | ❌ | ❌ | ✅ | ❌ | ❌ | | ||
| Task | ❌ | ✅ | ✅ | ✅ | ✅ | | ||
|
||
## Supported types | ||
|
||
|
@@ -28,38 +31,40 @@ General implementation of [HubSpot](https://developers.hubspot.com/docs/api/crm/ | |
## Usage Examples | ||
|
||
Basic SDK client configuration | ||
|
||
```kotlin | ||
// 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 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", | ||
apiBasePath = "https://api.hubapi.com", | ||
|
||
// Found in HubSpot company management -> Integrations -> API Keys -> Active API Key | ||
apiKey = "xxx" | ||
// Found in HubSpot company management -> Integrations -> API Keys -> Active API Key | ||
apiKey = "xxx" | ||
) | ||
``` | ||
|
||
## #️⃣ Company entity | ||
|
||
### Create brand-new company | ||
|
||
```kotlin | ||
val companyRequest = CompanyRequest( | ||
properties = MyCustomCompanyProperties( | ||
name = "John Doe", | ||
age = 34, | ||
email = "[email protected]", | ||
newsletter = true | ||
) | ||
properties = MyCustomCompanyProperties( | ||
name = "John Doe", | ||
age = 34, | ||
email = "[email protected]", | ||
newsletter = true | ||
) | ||
) | ||
|
||
val companyResponse = companiesClient.createCompany(companyRequest) | ||
|
@@ -69,14 +74,15 @@ println(companyResponse.properties["name"]) // John Doe | |
``` | ||
|
||
### Change existing company | ||
|
||
```kotlin | ||
val companyRequest = CompanyRequest( | ||
properties = MyCustomCompanyProperties( | ||
name = "John Doe", | ||
age = 34, | ||
email = "[email protected]", | ||
newsletter = true | ||
) | ||
properties = MyCustomCompanyProperties( | ||
name = "John Doe", | ||
age = 34, | ||
email = "[email protected]", | ||
newsletter = true | ||
) | ||
) | ||
|
||
val companyResponse = companiesClient.changeCompany(123456789, companyRequest) | ||
|
@@ -88,22 +94,23 @@ println(companyResponse.properties["name"]) // John Doe | |
## #️⃣ Custom objects | ||
|
||
### Create brand-new custom object record | ||
|
||
```kotlin | ||
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), | ||
) | ||
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 | ||
|
@@ -114,16 +121,18 @@ 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 | ||
|
||
```kotlin | ||
|
||
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 | ||
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) | ||
|
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
2 changes: 1 addition & 1 deletion
2
...n/associations/AssociationTypeCategory.kt → ...omain/associations/AssociationCategory.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package org.boomevents.hubspot.domain.associations | ||
|
||
enum class AssociationTypeCategory { | ||
enum class AssociationCategory { | ||
HUBSPOT_DEFINED, | ||
USER_DEFINED | ||
} |
11 changes: 11 additions & 0 deletions
11
hubspot/src/main/kotlin/org/boomevents/hubspot/domain/associations/AssociationObject.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.boomevents.hubspot.domain.associations | ||
|
||
data class AssociationObject( | ||
val to: AssociationObjectTo, | ||
val types: List<AssociationObjectType> | ||
) { | ||
|
||
data class AssociationObjectTo( | ||
val id: Long | ||
) | ||
} |
9 changes: 4 additions & 5 deletions
9
hubspot/src/main/kotlin/org/boomevents/hubspot/domain/associations/AssociationObjectType.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package org.boomevents.hubspot.domain.associations | ||
|
||
enum class AssociationObjectType(val value: String) { | ||
CONTACT("contact"), | ||
COMPANY("company"), | ||
DEAL("deal"), | ||
} | ||
data class AssociationObjectType( | ||
val associationCategory: AssociationCategory, | ||
val associationTypeId: Int | ||
) |
8 changes: 8 additions & 0 deletions
8
...pot/src/main/kotlin/org/boomevents/hubspot/domain/associations/AssociationObjectTypeId.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.boomevents.hubspot.domain.associations | ||
|
||
enum class AssociationObjectTypeId(val value: String) { | ||
CONTACT("contact"), | ||
COMPANY("company"), | ||
DEAL("deal"), | ||
TASK("task") | ||
} |
8 changes: 0 additions & 8 deletions
8
hubspot/src/main/kotlin/org/boomevents/hubspot/domain/associations/AssociationParams.kt
This file was deleted.
Oops, something went wrong.
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
4 changes: 2 additions & 2 deletions
4
hubspot/src/main/kotlin/org/boomevents/hubspot/domain/associations/AssociationResult.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
package org.boomevents.hubspot.domain.associations | ||
|
||
class AssociationResult ( | ||
class AssociationResult( | ||
val status: String? = null, | ||
val results: Array<Any>? = null, | ||
val startedAt: String? = null, | ||
val completedAt: String? = null, | ||
val completedAt: String? = null | ||
) | ||
|
10 changes: 9 additions & 1 deletion
10
hubspot/src/main/kotlin/org/boomevents/hubspot/domain/associations/AssociationType.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
package org.boomevents.hubspot.domain.associations | ||
|
||
enum class AssociationType(val value: Int) { | ||
// Contact | ||
CONTACT_TO_COMPANY_PRIMARY(1), | ||
COMPANY_TO_CONTACT_PRIMARY(2), | ||
CONTACT_TO_COMPANY(279), | ||
|
||
// Company | ||
COMPANY_TO_CONTACT_PRIMARY(2), | ||
COMPANY_TO_CONTACT(280), | ||
|
||
// Task | ||
TASK_TO_COMPANY(192), | ||
TASK_TO_CONTACT(204), | ||
TASK_TO_DEAL(216) | ||
} |
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
13 changes: 13 additions & 0 deletions
13
hubspot/src/main/kotlin/org/boomevents/hubspot/domain/task/Task.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.boomevents.hubspot.domain.task | ||
|
||
import org.boomevents.hubspot.domain.DataEntity | ||
import java.math.BigInteger | ||
import java.time.LocalDateTime | ||
|
||
class Task( | ||
override val id: BigInteger, | ||
override val properties: Map<String, Any>, | ||
override val createdAt: LocalDateTime, | ||
override val updatedAt: LocalDateTime, | ||
override val archived: Boolean | ||
) : DataEntity |
Oops, something went wrong.