Skip to content

update_enabled in Brevo::CreateContact needs to be camelCased #12

@rachelgraves

Description

@rachelgraves

I was implementing creating or updating a contact in my app, but was being told ext_id had already been taken. On a hunch I switched update_enabled to be camel cased and it worked.

However, According to the docs, this should work as snake cased which conforms to ruby conventions.

class SyncContactWithBrevo
  extend Literal::Properties

  prop :user_id, Integer, :positional

  def self.call(user_id)
    new(user_id).call
  end

  def call
    api_client = Brevo::ContactsApi.new

    create_contact = Brevo::CreateContact.new(
      email: user.email,
      ext_id: user.id.to_s,
      attributes: {
        "FIRSTNAME": user.first_name,
        "LASTNAME": user.last_name,
        "OPT_IN": user.newsletter_consent.to_s
      },
      list_ids: [ 12 ],
      updateEnabled: true # does not work when `update_enabled`
    )

    begin
      api_client.create_contact(create_contact)
    rescue Brevo::ApiError => e
      debugger
    end
  end

  private

  def user
    @user ||= User.find(@user_id)
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions