Sha256: 5864c272c0cfec875c5a58f415c111db97cbb4c18f95b1680443243768a17e3b

Contents?: true

Size: 935 Bytes

Versions: 10

Compression:

Stored size: 935 Bytes

Contents

require 'time'

module Mrkt
  module CrudCustomActivities
    def get_list_of_custom_activity_types
      warn 'DEPRECATED: Use #get_activity_types instead of #get_list_of_custom_activity_types!'
      get_activity_types
    end

    def create_custom_activity(lead_id, activity_type_id, primary_attribute_value, attributes: {}, date: nil)
      date ||= Time.now
      date = date.utc.iso8601
      converted_attributes = convert_attribute_hash(attributes)

      input = [{
        leadId: lead_id,
        activityDate: date,
        activityTypeId: activity_type_id,
        primaryAttributeValue: primary_attribute_value,
        attributes: converted_attributes
      }]

      post_json('/rest/v1/activities/external.json') do
        { input: input }
      end
    end

    private

    def convert_attribute_hash(attributes)
      attributes.map do |key, value|
        { name: key, value: value }
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mrkt-1.2.2 lib/mrkt/concerns/crud_custom_activities.rb
mrkt-1.2.1 lib/mrkt/concerns/crud_custom_activities.rb
mrkt-1.2.0 lib/mrkt/concerns/crud_custom_activities.rb
mrkt-1.1.1 lib/mrkt/concerns/crud_custom_activities.rb
mrkt-1.1.0 lib/mrkt/concerns/crud_custom_activities.rb
mrkt-1.0.1 lib/mrkt/concerns/crud_custom_activities.rb
mrkt-1.0.0 lib/mrkt/concerns/crud_custom_activities.rb
mrkt-0.11.1 lib/mrkt/concerns/crud_custom_activities.rb
mrkt-0.11.0 lib/mrkt/concerns/crud_custom_activities.rb
mrkt-0.10.0 lib/mrkt/concerns/crud_custom_activities.rb