Class: CleverTap::Uploader
- Inherits:
-
Object
- Object
- CleverTap::Uploader
- Defined in:
- lib/clever_tap/uploader.rb
Overview
unit uploading profile data to CleverTap
Constant Summary collapse
- HTTP_PATH =
'upload'.freeze
- TYPE_EVENT =
:event
- TYPE_PROFILE =
:profile
- ENTITY_DATA_NAMES =
{ TYPE_EVENT => 'evtData', TYPE_PROFILE => 'profileData' }.freeze
Instance Attribute Summary collapse
-
#date_field ⇒ Object
readonly
Returns the value of attribute date_field.
-
#dry_run ⇒ Object
readonly
Returns the value of attribute dry_run.
-
#event_name ⇒ Object
readonly
Returns the value of attribute event_name.
-
#identity_field ⇒ Object
readonly
Returns the value of attribute identity_field.
-
#records ⇒ Object
readonly
Returns the value of attribute records.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #call(client) ⇒ Object
-
#initialize(records, identity_field:, date_field: nil, event_name: nil, dry_run: false) ⇒ Uploader
constructor
TODO: make defaults configurable date_field should be a date object responding to ‘to_i` which should returns epoch time profile respond to .to_h.
Constructor Details
#initialize(records, identity_field:, date_field: nil, event_name: nil, dry_run: false) ⇒ Uploader
TODO: make defaults configurable date_field should be a date object responding to ‘to_i` which should returns epoch time profile respond to .to_h
20 21 22 23 24 25 26 27 28 |
# File 'lib/clever_tap/uploader.rb', line 20 def initialize(records, identity_field:, date_field: nil, event_name: nil, dry_run: false) @type = event_name ? TYPE_EVENT : TYPE_PROFILE @records = records @identity_field = identity_field @date_field = date_field @event_name = event_name @dry_run = dry_run end |
Instance Attribute Details
#date_field ⇒ Object (readonly)
Returns the value of attribute date_field.
14 15 16 |
# File 'lib/clever_tap/uploader.rb', line 14 def date_field @date_field end |
#dry_run ⇒ Object (readonly)
Returns the value of attribute dry_run.
14 15 16 |
# File 'lib/clever_tap/uploader.rb', line 14 def dry_run @dry_run end |
#event_name ⇒ Object (readonly)
Returns the value of attribute event_name.
14 15 16 |
# File 'lib/clever_tap/uploader.rb', line 14 def event_name @event_name end |
#identity_field ⇒ Object (readonly)
Returns the value of attribute identity_field.
14 15 16 |
# File 'lib/clever_tap/uploader.rb', line 14 def identity_field @identity_field end |
#records ⇒ Object (readonly)
Returns the value of attribute records.
14 15 16 |
# File 'lib/clever_tap/uploader.rb', line 14 def records @records end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
14 15 16 |
# File 'lib/clever_tap/uploader.rb', line 14 def type @type end |
Instance Method Details
#call(client) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/clever_tap/uploader.rb', line 30 def call(client) response = client.post(HTTP_PATH, build_request_body) do |request| request.params.merge!(dryRun: 1) if dry_run end parse_response(response) end |