class PatientZero::Analytics::Base

Attributes

end_date[RW]
source_id[RW]
start_date[RW]
token[RW]

Public Class Methods

new(token:, source_id:, start_date: nil, end_date: nil) click to toggle source
# File lib/patient_zero/analytics/base.rb, line 8
def initialize token:, source_id:, start_date: nil, end_date: nil
  @token = token
  @source_id = source_id
  @end_date = end_date || Date.today.to_s
  @start_date = start_date || Date.today.prev_day(7).to_s
end

Public Instance Methods

messages() click to toggle source
# File lib/patient_zero/analytics/base.rb, line 23
def messages
  analytical_data['messages'].map { |message| Message.for_platform message['platform'], message }.compact
end
name() click to toggle source
# File lib/patient_zero/analytics/base.rb, line 15
def name
  analytical_data['name']
end
platform() click to toggle source
# File lib/patient_zero/analytics/base.rb, line 19
def platform
  analytical_data['platform']
end
total_posts() click to toggle source
# File lib/patient_zero/analytics/base.rb, line 27
def total_posts
  messages.count
end

Private Instance Methods

analytical_data() click to toggle source
# File lib/patient_zero/analytics/base.rb, line 33
def analytical_data
  @analytical_data ||= get('/mobile/api/v1/analytics', client_token: token,
                                                       social_object_uid: source_id,
                                                       start_date: start_date,
                                                       end_date: end_date)['stats'].first
end