Class: Blastengine::Report

Inherits:
Download show all
Includes:
Blastengine
Defined in:
lib/blastengine/report.rb

Constant Summary

Constants included from Blastengine

BASE_PATH, DOMAIN, VERSION

Instance Attribute Summary collapse

Attributes inherited from Base

#created_time, #delivery_time, #delivery_type, #drop_count, #hard_error_count, #open_count, #sent_count, #soft_error_count, #updated_time

Instance Method Summary collapse

Methods included from Blastengine

#email, initialize

Methods inherited from Download

#download

Methods inherited from Base

#cancel, #client, client, #delete, #set, #sets, #unsubscribe

Constructor Details

#initialize(delivery_id) ⇒ Report

Returns a new instance of Report.



7
8
9
10
# File 'lib/blastengine/report.rb', line 7

def initialize delivery_id
  @delivery_id = delivery_id
  create
end

Instance Attribute Details

#delivery_idObject

Returns the value of attribute delivery_id.



6
7
8
# File 'lib/blastengine/report.rb', line 6

def delivery_id
  @delivery_id
end

#job_idObject

Returns the value of attribute job_id.



6
7
8
# File 'lib/blastengine/report.rb', line 6

def job_id
  @job_id
end

#mail_open_file_urlObject

Returns the value of attribute mail_open_file_url.



6
7
8
# File 'lib/blastengine/report.rb', line 6

def mail_open_file_url
  @mail_open_file_url
end

#percentageObject

Returns the value of attribute percentage.



6
7
8
# File 'lib/blastengine/report.rb', line 6

def percentage
  @percentage
end

#reportObject

Returns the value of attribute report.



6
7
8
# File 'lib/blastengine/report.rb', line 6

def report
  @report
end

#statusObject

Returns the value of attribute status.



6
7
8
# File 'lib/blastengine/report.rb', line 6

def status
  @status
end

#total_countObject

Returns the value of attribute total_count.



6
7
8
# File 'lib/blastengine/report.rb', line 6

def total_count
  @total_count
end

Instance Method Details

#createObject



12
13
14
15
16
17
18
# File 'lib/blastengine/report.rb', line 12

def create
  # APIリクエスト用のパス
  path = "/deliveries/#{@delivery_id}/analysis/report"
  res = @@client.post path
  @job_id = res["job_id"]
  return @job_id
end

#finish?Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
26
27
28
29
# File 'lib/blastengine/report.rb', line 20

def finish?
  # APIリクエスト用のパス
  path = "/deliveries/-/analysis/report/#{@job_id}"
  res = @@client.get path
  @percentage = res["percentage"]
  @status = res["status"]
  @total_count = res["total_count"] unless res["total_count"].nil?
  @mail_open_file_url = res["mail_open_file_url"] unless res["mail_open_file_url"].nil?
  return @percentage == 100
end

#getObject



31
32
33
34
35
36
37
38
# File 'lib/blastengine/report.rb', line 31

def get
  return @report unless @report.nil?
  return nil unless @percentage == 100
  path = "/deliveries/-/analysis/report/#{@job_id}/download"
  res = @@client.get path, true
  @report = download res
  @report
end