Class: SimpleSegment::Batch
- Inherits:
-
Object
- Object
- SimpleSegment::Batch
show all
- Includes:
- Utils
- Defined in:
- lib/simple_segment/batch.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Utils
included, #isoify_dates, #isoify_dates!, #maybe_datetime_in_iso8601, #symbolize_keys
Constructor Details
#initialize(client, payload = { batch: [] }) ⇒ Batch
Returns a new instance of Batch.
11
12
13
14
|
# File 'lib/simple_segment/batch.rb', line 11
def initialize(client, payload = { batch: [] })
@client = client
@payload = payload
end
|
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
5
6
7
|
# File 'lib/simple_segment/batch.rb', line 5
def client
@client
end
|
#payload ⇒ Object
Returns the value of attribute payload.
5
6
7
|
# File 'lib/simple_segment/batch.rb', line 5
def payload
@payload
end
|
Class Method Details
.deserialize(client, payload) ⇒ Object
7
8
9
|
# File 'lib/simple_segment/batch.rb', line 7
def self.deserialize(client, payload)
new(client, symbolize_keys(payload))
end
|
Instance Method Details
#commit ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/simple_segment/batch.rb', line 44
def commit
if payload[:batch].length.zero?
raise ArgumentError, 'A batch must contain at least one action'
end
Request.new(client).post('/v1/import', payload)
end
|
#context=(context) ⇒ Object
32
33
34
|
# File 'lib/simple_segment/batch.rb', line 32
def context=(context)
payload[:context] = context
end
|
#group(options) ⇒ Object
28
29
30
|
# File 'lib/simple_segment/batch.rb', line 28
def group(options)
add(Operations::Group, options, __method__)
end
|
#identify(options) ⇒ Object
16
17
18
|
# File 'lib/simple_segment/batch.rb', line 16
def identify(options)
add(Operations::Identify, options, __method__)
end
|
#integrations=(integrations) ⇒ Object
36
37
38
|
# File 'lib/simple_segment/batch.rb', line 36
def integrations=(integrations)
payload[:integrations] = integrations
end
|
#page(options) ⇒ Object
24
25
26
|
# File 'lib/simple_segment/batch.rb', line 24
def page(options)
add(Operations::Page, options, __method__)
end
|
#serialize ⇒ Object
40
41
42
|
# File 'lib/simple_segment/batch.rb', line 40
def serialize
payload
end
|
#track(options) ⇒ Object
20
21
22
|
# File 'lib/simple_segment/batch.rb', line 20
def track(options)
add(Operations::Track, options, __method__)
end
|