Sha256: 46a1b1d02b449e2c39b22b76afccc74c69032777372685f78716133b3c513ae5

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

module Services
  module Hubspot
    module Timeline
      class CreateTemplate
        def initialize(template_params)
          @template_params = template_params
        end

        def call
          api_client = api_client_with_hapikey
          create_api = ::Hubspot::Crm::Timeline::TemplatesApi.new(api_client)
          create_api.create(
            ENV['HUBSPOT_APPLICATION_ID'],
            timeline_event_template_create_request: template_create_request,
            auth_names: 'hapikey'
          )
        end

        private

        def template_create_request
          ::Hubspot::Crm::Timeline::TimelineEventTemplateCreateRequest.new(
            object_type: @template_params[:target_record_type],
            name: 'Test event template name',
            header_template: @template_params[:header_template],
            detail_template: @template_params[:detail_template]
          )
        end

        def api_client_with_hapikey
          config = ::Hubspot::Crm::Timeline::Configuration.new do |config|
            config.api_key = { 'hapikey' => ENV['HUBSPOT_DEVELOPER_API_KEY'] }
          end
          ::Hubspot::Crm::Timeline::ApiClient.new(config)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hubspot-api-client-9.0.0 sample-apps/timeline-events-app/app/lib/services/hubspot/timeline/create_template.rb
hubspot-api-client-8.0.1 sample-apps/timeline-events-app/app/lib/services/hubspot/timeline/create_template.rb
hubspot-api-client-8.0.0 sample-apps/timeline-events-app/app/lib/services/hubspot/timeline/create_template.rb
hubspot-api-client-7.3.0 sample-apps/timeline-events-app/app/lib/services/hubspot/timeline/create_template.rb