belong-inc / go-hubspot

HubSpot API Go client
Apache License 2.0
35 stars 26 forks source link

Add support for hubspot single email send via marketing/transactional endpoint. #12

Closed sblackstone closed 1 year ago

sblackstone commented 1 year ago

This PR adds support for a using the single email send API.

https://developers.hubspot.com/docs/api/marketing/transactional-emails

This maps to a POST /marketing/v3/transactional/single-email/send

Usage Example:

    props := make(map[string]string)
    props["favoritecolor"] = "green"
    res2, err := client.Marketing.Transactional.SendSingleEmail(&hs.SendSingleEmailProperties{
        EmailId: "xxxxxxxxxxxx",
        Message: &hs.SendSingleEmailMessage{
            To:     "testing@example.com",
            SendId: id.String(),
        },
        ContactProperties: &hs.Contact{
            FirstName: hs.NewString("Stephen"),
        },
        CustomProperties: props,
    })

On a successful request, this will return:

&{RequestedAt:2023-01-31T20:34:26.575Z StatusId:Hv-ltMeaTXqm_kmxDE0w8AAAAYYJiboWAWm-0Q== Status:PENDING}
ttyfky commented 1 year ago

Thank you for the PR! I gave some comments so please take a look.

sblackstone commented 1 year ago

Addressed all requested changes with fixes.

Updated sample at the top of this PR to reflect naming schemes.

Re-ran tests against API and everything appears to still be working.