Class: Blastengine::Job

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

Constant Summary

Constants included from Blastengine

BASE_PATH, DOMAIN, VERSION

Instance Attribute Summary collapse

Attributes inherited from Base

#created_time, #delivery_id, #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, #get, #set, #sets, #unsubscribe

Constructor Details

#initialize(id) ⇒ Job

Returns a new instance of Job.



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

def initialize id
  @job_id = id
end

Instance Attribute Details

#error_file_urlObject

Returns the value of attribute error_file_url.



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

def error_file_url
  @error_file_url
end

#failed_countObject

Returns the value of attribute failed_count.



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

def failed_count
  @failed_count
end

#job_idObject

Returns the value of attribute job_id.



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

def job_id
  @job_id
end

#percentageObject

Returns the value of attribute percentage.



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

def percentage
  @percentage
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

#success_countObject

Returns the value of attribute success_count.



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

def success_count
  @success_count
end

#total_countObject

Returns the value of attribute total_count.



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

def total_count
  @total_count
end

Instance Method Details

#error_messageObject



24
25
26
27
28
29
30
31
# File 'lib/blastengine/job.rb', line 24

def error_message
  return @error_message unless @error_message.nil?
  return nil if @error_file_url.nil?
  path = "/deliveries/-/emails/import/#{@job_id}/errorinfo/download"
  res = @@client.get path, true
  @error_message = download res
  @error_message
end

#finish?Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/blastengine/job.rb', line 11

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