Class: CleverTap
- Inherits:
-
Object
- Object
- CleverTap
- Defined in:
- lib/clever_tap.rb,
lib/clever_tap/event.rb,
lib/clever_tap/client.rb,
lib/clever_tap/config.rb,
lib/clever_tap/entity.rb,
lib/clever_tap/profile.rb,
lib/clever_tap/version.rb,
lib/clever_tap/response.rb,
lib/clever_tap/uploader.rb,
lib/clever_tap/failed_response.rb,
lib/clever_tap/successful_response.rb
Overview
the main module of the system
Defined Under Namespace
Classes: Client, Config, Entity, Event, FailedResponse, MissingEventNameError, MissingIdentityError, NoDataError, NotConsistentArrayError, Profile, Response, SuccessfulResponse, Uploader
Constant Summary collapse
- VERSION =
'0.3.0'.freeze
Class Attribute Summary collapse
-
.account_id ⇒ Object
Returns the value of attribute account_id.
-
.account_passcode ⇒ Object
Returns the value of attribute account_passcode.
-
.identity_field ⇒ Object
Returns the value of attribute identity_field.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
Instance Method Summary collapse
- #client ⇒ Object
-
#initialize(**params) {|@config| ... } ⇒ CleverTap
constructor
A new instance of CleverTap.
- #upload_event(event, **options) ⇒ Object
- #upload_events(events, name:, **rest) ⇒ Object
- #upload_profile(profile, **options) ⇒ Object
- #upload_profiles(profiles, **options) ⇒ Object
Constructor Details
Class Attribute Details
.account_id ⇒ Object
Returns the value of attribute account_id.
22 23 24 |
# File 'lib/clever_tap.rb', line 22 def account_id @account_id end |
.account_passcode ⇒ Object
Returns the value of attribute account_passcode.
23 24 25 |
# File 'lib/clever_tap.rb', line 23 def account_passcode @account_passcode end |
.identity_field ⇒ Object
Returns the value of attribute identity_field.
21 22 23 |
# File 'lib/clever_tap.rb', line 21 def identity_field @identity_field end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
15 16 17 |
# File 'lib/clever_tap.rb', line 15 def config @config end |
Class Method Details
.setup {|_self| ... } ⇒ Object
25 26 27 |
# File 'lib/clever_tap.rb', line 25 def setup yield(self) end |
Instance Method Details
#client ⇒ Object
38 39 40 |
# 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) ⇒ Object
52 53 54 |
# File 'lib/clever_tap.rb', line 52 def upload_event(event, **) upload_events([event], ) end |
#upload_events(events, name:, **rest) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/clever_tap.rb', line 42 def upload_events(events, name:, **rest) = rest.merge(event_name: name, identity_field: config.identity_field) response = Uploader.new(events, ).call(client) normalize_response(response, records: events) rescue Faraday::Error::TimeoutError, Faraday::Error::ClientError => e FailedResponse.new(records: events, message: e.) end |
#upload_profile(profile, **options) ⇒ Object
65 66 67 |
# File 'lib/clever_tap.rb', line 65 def upload_profile(profile, **) upload_profiles([profile], ) end |
#upload_profiles(profiles, **options) ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/clever_tap.rb', line 56 def upload_profiles(profiles, **) = .merge(identity_field: config.identity_field) response = Uploader.new(profiles, **).call(client) normalize_response(response, records: profiles) rescue Faraday::Error::TimeoutError, Faraday::Error::ClientError => e FailedResponse.new(records: profiles, message: e.) end |