Sha256: c33a4a02c1b1053338cfc4b85a739af84a02a2b0c5dd8021d259be9dcb7c93fd
Contents?: true
Size: 1019 Bytes
Versions: 6
Compression:
Stored size: 1019 Bytes
Contents
module SplitIoClient module Api class Impressions < Client def initialize(api_key, config, impressions) @config = config @api_key = api_key @impressions = impressions end def post if @impressions.empty? @config.logger.debug('No impressions to report') if @config.debug_enabled return end result = post_api("#{@config.events_uri}/testImpressions/bulk", @config, @api_key, @impressions) if result.status / 100 != 2 @config.logger.error("Unexpected status code while posting impressions: #{result.status}") else @config.logger.debug("Impressions reported: #{total_impressions(@impressions)}") if @config.debug_enabled end end def total_impressions(impressions) return 0 if impressions.nil? impressions.reduce(0) do |impressions_count, impression| impressions_count += impression[:keyImpressions].length end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems