class CleverTap
the main module of the system
Constants
- VERSION
Attributes
account_id[RW]
account_passcode[RW]
identity_field[RW]
Never instantiated. Variables are stored in the singleton_class.
config[R]
Public Class Methods
new(**params) { |config| ... }
click to toggle source
# File lib/clever_tap.rb, line 30 def initialize(**params) @config = Config.new(params) yield(@config) if block_given? @config.validate @config.freeze end
setup() { |self| ... }
click to toggle source
# File lib/clever_tap.rb, line 25 def setup yield(self) end
Public Instance Methods
client()
click to toggle source
# File lib/clever_tap.rb, line 38 def client @client ||= Client.new(config.account_id, config.passcode, &config.configure_faraday) end
upload_event(event, **options)
click to toggle source
# File lib/clever_tap.rb, line 52 def upload_event(event, **options) upload_events([event], options) end
upload_events(events, name:, **rest)
click to toggle source
# File lib/clever_tap.rb, line 42 def upload_events(events, name:, **rest) options = rest.merge(event_name: name, identity_field: config.identity_field) response = Uploader.new(events, options).call(client) normalize_response(response, records: events) rescue Faraday::Error::TimeoutError, Faraday::Error::ClientError => e FailedResponse.new(records: events, message: e.message) end
upload_profile(profile, **options)
click to toggle source
# File lib/clever_tap.rb, line 65 def upload_profile(profile, **options) upload_profiles([profile], options) end
upload_profiles(profiles, **options)
click to toggle source
# File lib/clever_tap.rb, line 56 def upload_profiles(profiles, **options) options = options.merge(identity_field: config.identity_field) response = Uploader.new(profiles, **options).call(client) normalize_response(response, records: profiles) rescue Faraday::Error::TimeoutError, Faraday::Error::ClientError => e FailedResponse.new(records: profiles, message: e.message) end
Private Instance Methods
normalize_response(response, records:)
click to toggle source
# File lib/clever_tap.rb, line 71 def normalize_response(response, records:) # TODO: handle JSON::ParserError if response.success? SuccessfulResponse.new(JSON.parse(response.body)) else FailedResponse.new(records: records, code: response.status, message: response.body) end end