Class: CrowdFlower::Order

Inherits:
Base
  • Object
show all
Defined in:
lib/crowdflower/order.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#last_response

Instance Method Summary collapse

Methods inherited from Base

connect, #connect, connect!, connect_config!, connect_domain!, connection, #connection, delete, get, post, put, verify_response

Constructor Details

#initialize(job) ⇒ Order

Returns a new instance of Order.



5
6
7
8
9
# File 'lib/crowdflower/order.rb', line 5

def initialize(job)
  super job.connection
  @job = job
  connect
end

Instance Attribute Details

#jobObject (readonly)

Returns the value of attribute job.



3
4
5
# File 'lib/crowdflower/order.rb', line 3

def job
  @job
end

Instance Method Details

#debit(units_count = 1, channels = ["on_demand"]) ⇒ Object

defaults to on_demand; pass in diff channel name to launch job with that channel use job.enable_channels(“channel_name”) if you to keep on_demand and add another channel



17
18
19
# File 'lib/crowdflower/order.rb', line 17

def debit(units_count = 1, channels = ["on_demand"])
  connection.post(resource_uri, {:body => {:debit => {:units_count => units_count}, :channels => channels}})
end

#resource_uriObject



11
12
13
# File 'lib/crowdflower/order.rb', line 11

def resource_uri
  "/jobs/#{@job.id}/orders.json"
end