Class: RudderAnalyticsSync::Operations::Group

Inherits:
Operation
  • Object
show all
Defined in:
lib/rudder_analytics_sync/operations/group.rb

Constant Summary

Constants included from Constants

Constants::BASE_URL, Constants::DEFAULT_CONTEXT, Constants::DEFAULT_HEADERS, Constants::MAX_BATCH_SIZE, Constants::MAX_MESSAGE_SIZE

Constants included from Utils

Utils::UTC_OFFSET_WITHOUT_COLON, Utils::UTC_OFFSET_WITH_COLON

Instance Method Summary collapse

Methods inherited from Operation

#initialize, #make_context

Methods included from Utils

#date_in_iso8601, #formatted_offset, included, #isoify_dates, #isoify_dates!, #maybe_datetime_in_iso8601, #seconds_to_utc_offset, #symbolize_keys, #time_in_iso8601, #uid, #valid_date?

Constructor Details

This class inherits a constructor from RudderAnalyticsSync::Operations::Operation

Instance Method Details

#build_payloadObject

Raises:

  • (ArgumentError)


17
18
19
20
21
22
23
24
25
# File 'lib/rudder_analytics_sync/operations/group.rb', line 17

def build_payload
  raise ArgumentError, 'group_id must be present' \
    unless options[:group_id]

  base_payload.merge(
    traits: options[:traits] && isoify_dates!(options[:traits]),
    groupId: options[:group_id]
  )
end

#callObject



6
7
8
9
10
11
12
13
14
15
# File 'lib/rudder_analytics_sync/operations/group.rb', line 6

def call
  batch = build_payload.merge(
    type: 'group'
  )
  if batch.inspect.length > MAX_MESSAGE_SIZE
    raise ArgumentError, 'Max message size is 32 KB'
  end

  request.post('/v1/batch', batch: [batch])
end