class Gophr::Job

Attributes

attributes[RW]
job_id[RW]

Public Class Methods

new(attributes = {}, job_id = nil) click to toggle source
# File lib/gophr/job.rb, line 5
def initialize(attributes = {}, job_id = nil)
  @job_id = job_id
  @attributes = attributes
end

Public Instance Methods

cancel!() click to toggle source
# File lib/gophr/job.rb, line 43
def cancel!
  response = Jobs::Cancel.new(job_id: job_id).call

  if response.is_a?(Hash)
    true
  else
    response
  end
end
cancelation_cost() click to toggle source
# File lib/gophr/job.rb, line 53
def cancelation_cost
  response = Jobs::CancelationCost.new(job_id: job_id).call

  if response.is_a?(Hash)
    response['data']['cancelation_cost']
  else
    response
  end
end
confirm!() click to toggle source
# File lib/gophr/job.rb, line 32
def confirm!
  response = Jobs::Confirm.new(job_id: job_id).call

  if response.is_a?(Hash)
    assign_attributes(response['data'])
    self
  else
    response
  end
end
create() click to toggle source
# File lib/gophr/job.rb, line 10
def create
  response = Jobs::Create.new(attributes).call

  if response.is_a?(Hash)
    assign_attributes(response['data'])
    self
  else
    response
  end
end
simulate_callback() click to toggle source
# File lib/gophr/job.rb, line 63
def simulate_callback
  Jobs::SimulateCallback.new(job_id: job_id).call
end
update(new_attributes = {}) click to toggle source
# File lib/gophr/job.rb, line 21
def update(new_attributes = {})
  response = Jobs::Update.new(new_attributes.merge!(job_id: job_id)).call

  if response.is_a?(Hash)
    assign_attributes(response['data'].merge!(new_attributes))
    self
  else
    response
  end
end

Private Instance Methods

assign_attributes(new_attributes = {}) click to toggle source
# File lib/gophr/job.rb, line 84
def assign_attributes(new_attributes = {})
  new_attributes.each do |property, value|
    self.send("#{property}=", value)
  end
end