Class: Conversant::V3::Services::LMS::Partner::Analytics

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

Overview

LMS analytics service for partner-level reporting

Provides partner-level analytics and reporting for Live Media Streaming services including live duration, recording duration, transcoding metrics, and job statistics across multiple customer accounts.

Since:

  • 1.0.12

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ Analytics

Initialize partner LMS analytics service

Parameters:

Since:

  • 1.0.12



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

def initialize(parent)
  @parent = parent
end

Instance Attribute Details

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

Returns the parent LMS service instance.

Returns:

Since:

  • 1.0.12



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

def parent
  @parent
end

Instance Method Details

#businessBusiness

Get business service instance

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

Examples:

Access business methods

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

Returns:

  • (Business)

    business service for LMS aggregated analytics

Since:

  • 1.0.15



54
55
56
# File 'lib/conversant/v3/services/lms/partner/analytics.rb', line 54

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

#duration_of_live(**args) ⇒ Array

Get duration of live streaming for business usage reporting

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)

    live streaming duration data, or empty array on error

Since:

  • 1.0.8



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/conversant/v3/services/lms/partner/analytics.rb', line 66

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

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

  response = @parent.send(:call, 'GET', "/v4/reporting/lms/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

#duration_of_live_recording(**args) ⇒ Array

Get duration of live recording for business usage reporting

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)

    recording duration data, or empty array on error

Since:

  • 1.0.8



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/conversant/v3/services/lms/partner/analytics.rb', line 93

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

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

  response = @parent.send(:call, 'GET', "/v4/reporting/lms/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

#duration_v2_transcoding(params = {}) ⇒ Hash?

Get transcoding duration metrics (v2 endpoint)

Parameters:

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

    query parameters

Options Hash (params):

  • :startTime (String)

    start time

  • :endTime (String)

    end time

Returns:

  • (Hash, nil)

    transcoding duration data, or nil on error

Since:

  • 1.0.8



224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/conversant/v3/services/lms/partner/analytics.rb', line 224

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

  JSON.parse(response)
rescue StandardError => e
  @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.message}"
  nil
end

#durations(scope, params = {}) ⇒ Array

Get duration metrics by scope (live/recording/transcoding)

Parameters:

  • scope (String)

    scope type (e.g., 'live', 'recording', 'transcoding')

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

    query parameters

Returns:

  • (Array)

    duration data for specified scope, or empty array on error

Since:

  • 1.0.8



146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/conversant/v3/services/lms/partner/analytics.rb', line 146

def durations(scope, params = {})
  query_string = params.map { |k, v| "#{k}=#{v}" }.join('&')
  uri = "/v2/reporting/lms/#{scope}/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

#jobs(params = {}) ⇒ Hash

Get transcoding job count metrics

Parameters:

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

    query parameters

Options Hash (params):

  • :startTime (String)

    start time

  • :endTime (String)

    end time

Returns:

  • (Hash)

    job count data, or nil on error

Since:

  • 1.0.8



205
206
207
208
209
210
211
212
213
214
# File 'lib/conversant/v3/services/lms/partner/analytics.rb', line 205

def jobs(params = {})
  query_string = params.map { |k, v| "#{k}=#{v}" }.join('&')
  uri = '/reporting/lms/transcoding/number'
  uri += "?#{query_string}" unless query_string.empty?
  response = @parent.send(:call, 'GET', uri)
  JSON.parse(response)
rescue StandardError => e
  @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.message}"
  nil
end

#no_of_live_jobs(**args) ⇒ Array

Get number of live streaming jobs for business usage reporting

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)

    live job count data, or empty array on error

Since:

  • 1.0.8



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/conversant/v3/services/lms/partner/analytics.rb', line 120

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

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

  response = @parent.send(:call, 'GET', "/v4/reporting/lms/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

#recordings(params = {}) ⇒ Hash

Get recording duration metrics

Parameters:

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

    query parameters

Options Hash (params):

  • :startTime (String)

    start time

  • :endTime (String)

    end time

Returns:

  • (Hash)

    recording duration data, or nil on error

Since:

  • 1.0.8



186
187
188
189
190
191
192
193
194
195
# File 'lib/conversant/v3/services/lms/partner/analytics.rb', line 186

def recordings(params = {})
  query_string = params.map { |k, v| "#{k}=#{v}" }.join('&')
  uri = '/reporting/lms/recording/duration'
  uri += "?#{query_string}" unless query_string.empty?
  response = @parent.send(:call, 'GET', uri)
  JSON.parse(response)
rescue StandardError => e
  @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.message}"
  nil
end

#reportReport

Get report service instance

Provides access to detailed partner-level reporting for LMS services including transcoding, recording, jobs, and DRM analytics.

Examples:

Access report methods

lms = Conversant::V3.lms(12345)
report = lms.partner.analytics.report
transcodings = report.transcodings(startTime: '2025-01-01', endTime: '2025-01-31')

Returns:

  • (Report)

    report service for LMS detailed analytics

Since:

  • 1.0.15



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

def report
  @report ||= Report.new(self)
end

#transcodings(params = {}) ⇒ Hash

Get transcoding duration metrics

Parameters:

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

    query parameters

Options Hash (params):

  • :startTime (String)

    start time

  • :endTime (String)

    end time

Returns:

  • (Hash)

    transcoding duration data, or nil on error

Since:

  • 1.0.8



167
168
169
170
171
172
173
174
175
176
# File 'lib/conversant/v3/services/lms/partner/analytics.rb', line 167

def transcodings(params = {})
  query_string = params.map { |k, v| "#{k}=#{v}" }.join('&')
  uri = '/reporting/lms/transcoding/duration'
  uri += "?#{query_string}" unless query_string.empty?
  response = @parent.send(:call, 'GET', uri)
  JSON.parse(response)
rescue StandardError => e
  @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.message}"
  nil
end