Class: EatabitRails::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/eatabit_rails/job.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Job

Returns a new instance of Job.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/eatabit_rails/job.rb', line 22

def initialize(attributes)
  @id                 = attributes['id']
  @external_id        = attributes['external_id']
  @body               = attributes['body']
  @state              = attributes['state']
  @environment        = attributes['environment']
  @pickup_minutes     = attributes['pickup_minutes']
  @delivery_minutes   = attributes['delivery_minutes']
  @status_url         = attributes['status_url']
  @status_url_method  = attributes['status_url_method']
  @created_at         = attributes['created_at']
  @fulfill_at         = attributes['fulfill_at']
  @api_version        = attributes['api_version']
  @expire_seconds     = attributes['expire_seconds']
  @expires_at         = attributes['expires_at']
  @account            = attributes['account']
  @printer            = attributes['printer']
end

Instance Attribute Details

#accountObject (readonly)

Returns the value of attribute account.



5
6
7
# File 'lib/eatabit_rails/job.rb', line 5

def 
  @account
end

#api_versionObject (readonly)

Returns the value of attribute api_version.



5
6
7
# File 'lib/eatabit_rails/job.rb', line 5

def api_version
  @api_version
end

#bodyObject (readonly)

Returns the value of attribute body.



5
6
7
# File 'lib/eatabit_rails/job.rb', line 5

def body
  @body
end

#created_atObject (readonly)

Returns the value of attribute created_at.



5
6
7
# File 'lib/eatabit_rails/job.rb', line 5

def created_at
  @created_at
end

#delivery_minutesObject (readonly)

Returns the value of attribute delivery_minutes.



5
6
7
# File 'lib/eatabit_rails/job.rb', line 5

def delivery_minutes
  @delivery_minutes
end

#environmentObject (readonly)

Returns the value of attribute environment.



5
6
7
# File 'lib/eatabit_rails/job.rb', line 5

def environment
  @environment
end

#expire_secondsObject (readonly)

Returns the value of attribute expire_seconds.



5
6
7
# File 'lib/eatabit_rails/job.rb', line 5

def expire_seconds
  @expire_seconds
end

#expires_atObject (readonly)

Returns the value of attribute expires_at.



5
6
7
# File 'lib/eatabit_rails/job.rb', line 5

def expires_at
  @expires_at
end

#external_idObject (readonly)

Returns the value of attribute external_id.



5
6
7
# File 'lib/eatabit_rails/job.rb', line 5

def external_id
  @external_id
end

#fulfill_atObject (readonly)

Returns the value of attribute fulfill_at.



5
6
7
# File 'lib/eatabit_rails/job.rb', line 5

def fulfill_at
  @fulfill_at
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/eatabit_rails/job.rb', line 5

def id
  @id
end

#pickup_minutesObject (readonly)

Returns the value of attribute pickup_minutes.



5
6
7
# File 'lib/eatabit_rails/job.rb', line 5

def pickup_minutes
  @pickup_minutes
end

#printerObject (readonly)

Returns the value of attribute printer.



5
6
7
# File 'lib/eatabit_rails/job.rb', line 5

def printer
  @printer
end

#stateObject (readonly)

Returns the value of attribute state.



5
6
7
# File 'lib/eatabit_rails/job.rb', line 5

def state
  @state
end

#status_urlObject (readonly)

Returns the value of attribute status_url.



5
6
7
# File 'lib/eatabit_rails/job.rb', line 5

def status_url
  @status_url
end

#status_url_methodObject (readonly)

Returns the value of attribute status_url_method.



5
6
7
# File 'lib/eatabit_rails/job.rb', line 5

def status_url_method
  @status_url_method
end

Class Method Details

.create(printer_id, job_attributes) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/eatabit_rails/job.rb', line 41

def self.create(printer_id, job_attributes)
  job_uri             = EatabitRails::REST::Uri.new.job printer_id
  params              = EatabitRails::REST::Uri.default_params
  response            = RestClient.post job_uri, job_attributes
  response_attributes = JSON.parse(response.body)['job']

  new response_attributes
end

.find(printer_id, job_id) ⇒ Object



50
51
52
53
54
55
56
57
# File 'lib/eatabit_rails/job.rb', line 50

def self.find(printer_id, job_id)
  job_uri             = EatabitRails::REST::Uri.new.job printer_id, job_id
  params              = EatabitRails::REST::Uri.default_params
  response            = RestClient.get job_uri, params
  response_attributes = JSON.parse(response.body)['job']

  new response_attributes
end