Class: HubspotClient::Client::Submission

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/hubspot_client/client/submission.rb

Constant Summary collapse

BASE_PATH_V3 =
'/submissions/v3/integration/secure/submit'

Instance Method Summary collapse

Constructor Details

#initialize(portal_id:, form_guid:, fields: [], context: {}, legal_consent_options: {}) ⇒ Submission

EXAMPLES: fields: [‘email’, value: ‘[email protected]’]

context:

pageUri: "https://example.com",
pageName: "Example page"

legal_consent_options:

consent: {
  consentToProcess: true,
  text: "I agree to allow #{company_name to store and process my personal data.",
  communications: []
}

}



27
28
29
30
31
32
33
# File 'lib/hubspot_client/client/submission.rb', line 27

def initialize(portal_id:, form_guid:, fields: [], context: {}, legal_consent_options: {})
  @portal_id             = portal_id
  @form_guid             = form_guid
  @fields                = fields
  @context               = context
  @legal_consent_options = legal_consent_options
end

Instance Method Details

#submitObject



35
36
37
38
# File 'lib/hubspot_client/client/submission.rb', line 35

def submit
  url = "#{BASE_PATH_V3}/#{@portal_id}/#{@form_guid}"
  self.class.post(url, body: body.to_json, headers: headers)
end