Class: Conversant::V3::Services::VMS::Partner::Analytics

Inherits:
Object
  • Object
show all
Defined in:
lib/conversant/v3/services/vms/partner/analytics.rb

Overview

VMS analytics service for partner-level reporting

Provides partner-level analytics and reporting for Video Management System services including VOD duration and transcoding metrics across multiple customer accounts.

Since:

  • 1.0.12

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ Analytics

Initialize partner VMS analytics service

Parameters:

Since:

  • 1.0.12



21
22
23
# File 'lib/conversant/v3/services/vms/partner/analytics.rb', line 21

def initialize(parent)
  @parent = parent
end

Instance Attribute Details

#parentConversant::V3::Services::VMS (readonly)

Returns the parent VMS service instance.

Returns:

Since:

  • 1.0.12



16
17
18
# File 'lib/conversant/v3/services/vms/partner/analytics.rb', line 16

def parent
  @parent
end

Instance Method Details

#businessBusiness

Get business service instance

Provides access to business-focused analytics that aggregate transcoding data for VOD billing and capacity planning.

Examples:

Access business methods

vms = Conversant::V3.vms(12345)
business = vms.partner.analytics.business
metrics = business.transcoding(startTime: Time.now.beginning_of_month)

Returns:

  • (Business)

    business service for VMS aggregated analytics

Since:

  • 1.0.16



37
38
39
# File 'lib/conversant/v3/services/vms/partner/analytics.rb', line 37

def business
  @business ||= Business.new(self)
end

#duration(params = {}) ⇒ Array

Get VMS transcoding duration metrics

Retrieves transcoding duration metrics for video processing operations, useful for capacity planning and billing calculations.

Examples:

Get transcoding duration for a year

duration = vms.partner.analytics.duration(year: "2025")
puts "Total transcoding: #{duration['total']} hours"

Parameters:

  • params (Hash) (defaults to: {})

    query parameters

Options Hash (params):

  • :year (String)

    year in YYYY format

Returns:

  • (Array)

    transcoding duration data, or empty array on error

Since:

  • 1.0.8



91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/conversant/v3/services/vms/partner/analytics.rb', line 91

def duration(params = {})
  query_string = params.map { |k, v| "#{k}=#{v}" }.join('&')
  uri = '/reporting/vms/transcoding/duration'
  uri += "?#{query_string}" unless query_string.empty?
  response = @parent.send(:call, 'GET', uri)
  return [] if response.nil?

  JSON.parse(response)&.map(&:with_indifferent_access) || []
rescue StandardError => e
  @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.message}"
  []
end

#duration_of_vod(**args) ⇒ Array

Get duration of VOD (Video on Demand) for business usage reporting

Retrieves VOD transcoding duration metrics aggregated by month and customer type for partner-level business reporting and billing purposes.

Examples:

Get VOD duration for current month

duration = vms.partner.analytics.duration_of_vod
puts "Total VOD duration: #{duration.first['total_duration']} minutes"

Parameters:

  • args (Hash)

    query parameters

Options Hash (**args):

  • :startTime (Time, String)

    start time for the report (defaults to beginning of current month)

  • :type (String, Integer)

    customer type filter (defaults to 2)

Returns:

  • (Array)

    VOD duration data, or empty array on error

Since:

  • 1.0.8



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/conversant/v3/services/vms/partner/analytics.rb', line 57

def duration_of_vod(**args)
  month, type, timestamp = queries(**args)

  payload = {
    month: month,
    selectType: 'vtd',
    customerType: type,
    _: timestamp
  }

  response = @parent.send(:call, 'GET', "/v5/reporting/vms/business/usage/search?#{payload.to_query}")
  return [] if response.nil?

  JSON.parse(response)&.map(&:with_indifferent_access) || []
rescue StandardError => e
  @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.message}"
  []
end