Class: Kempelen::API::Operations::CreateHit
- Defined in:
- lib/kempelen/API/operations/create_hit.rb
Constant Summary collapse
- AWS_OPERATION_NAME =
"CreateHIT".freeze
- AWS_RESPONSE_OBJECT =
"CreateHITResponse".freeze
Instance Attribute Summary collapse
-
#assignment_duration ⇒ Object
Returns the value of attribute assignment_duration.
-
#auto_approval_delay ⇒ Object
Returns the value of attribute auto_approval_delay.
-
#currency_code ⇒ Object
Returns the value of attribute currency_code.
-
#description ⇒ Object
Returns the value of attribute description.
-
#hit_type_id ⇒ Object
Returns the value of attribute hit_type_id.
-
#keywords ⇒ Object
Returns the value of attribute keywords.
-
#layout_id ⇒ Object
Returns the value of attribute layout_id.
-
#layout_parameters ⇒ Object
Returns the value of attribute layout_parameters.
-
#lifetime_in_seconds ⇒ Object
Returns the value of attribute lifetime_in_seconds.
-
#max_assignments ⇒ Object
Returns the value of attribute max_assignments.
-
#qualification_requirements ⇒ Object
Returns the value of attribute qualification_requirements.
-
#requester_annotation ⇒ Object
Returns the value of attribute requester_annotation.
-
#reward_amount ⇒ Object
Returns the value of attribute reward_amount.
-
#title ⇒ Object
Returns the value of attribute title.
-
#unique_request_token ⇒ Object
Returns the value of attribute unique_request_token.
Attributes inherited from Base
#client, #parameters, #query_string, #raw_response, #response_object, #timestamp
Instance Method Summary collapse
- #add_layout_parameter(name, value) ⇒ Object
- #create_parameters ⇒ Object
-
#initialize(client, hit_type_id, lifetime_in_seconds) {|_self| ... } ⇒ CreateHit
constructor
A new instance of CreateHit.
- #perform_operation ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(client, hit_type_id, lifetime_in_seconds) {|_self| ... } ⇒ CreateHit
Returns a new instance of CreateHit.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/kempelen/API/operations/create_hit.rb', line 26 def initialize(client, hit_type_id, lifetime_in_seconds, &block) super(client) @hit_type_id = hit_type_id @lifetime_in_seconds = lifetime_in_seconds.to_i @layout_id = nil @requester_annotation = nil @unique_request_token = nil @layout_parameters = [] @max_assignments = 1 @response_object = AWS_RESPONSE_OBJECT @auto_approval_delay = 2592000 @reward_amount = 0.0 @currency_code = "USD".freeze @qualification_requirements = [] yield self unless block == nil end |
Instance Attribute Details
#assignment_duration ⇒ Object
Returns the value of attribute assignment_duration.
18 19 20 |
# File 'lib/kempelen/API/operations/create_hit.rb', line 18 def assignment_duration @assignment_duration end |
#auto_approval_delay ⇒ Object
Returns the value of attribute auto_approval_delay.
19 20 21 |
# File 'lib/kempelen/API/operations/create_hit.rb', line 19 def auto_approval_delay @auto_approval_delay end |
#currency_code ⇒ Object
Returns the value of attribute currency_code.
14 15 16 |
# File 'lib/kempelen/API/operations/create_hit.rb', line 14 def currency_code @currency_code end |
#description ⇒ Object
Returns the value of attribute description.
17 18 19 |
# File 'lib/kempelen/API/operations/create_hit.rb', line 17 def description @description end |
#hit_type_id ⇒ Object
Returns the value of attribute hit_type_id.
5 6 7 |
# File 'lib/kempelen/API/operations/create_hit.rb', line 5 def hit_type_id @hit_type_id end |
#keywords ⇒ Object
Returns the value of attribute keywords.
15 16 17 |
# File 'lib/kempelen/API/operations/create_hit.rb', line 15 def keywords @keywords end |
#layout_id ⇒ Object
Returns the value of attribute layout_id.
6 7 8 |
# File 'lib/kempelen/API/operations/create_hit.rb', line 6 def layout_id @layout_id end |
#layout_parameters ⇒ Object
Returns the value of attribute layout_parameters.
7 8 9 |
# File 'lib/kempelen/API/operations/create_hit.rb', line 7 def layout_parameters @layout_parameters end |
#lifetime_in_seconds ⇒ Object
Returns the value of attribute lifetime_in_seconds.
8 9 10 |
# File 'lib/kempelen/API/operations/create_hit.rb', line 8 def lifetime_in_seconds @lifetime_in_seconds end |
#max_assignments ⇒ Object
Returns the value of attribute max_assignments.
9 10 11 |
# File 'lib/kempelen/API/operations/create_hit.rb', line 9 def max_assignments @max_assignments end |
#qualification_requirements ⇒ Object
Returns the value of attribute qualification_requirements.
21 22 23 |
# File 'lib/kempelen/API/operations/create_hit.rb', line 21 def qualification_requirements @qualification_requirements end |
#requester_annotation ⇒ Object
Returns the value of attribute requester_annotation.
10 11 12 |
# File 'lib/kempelen/API/operations/create_hit.rb', line 10 def requester_annotation @requester_annotation end |
#reward_amount ⇒ Object
Returns the value of attribute reward_amount.
13 14 15 |
# File 'lib/kempelen/API/operations/create_hit.rb', line 13 def reward_amount @reward_amount end |
#title ⇒ Object
Returns the value of attribute title.
16 17 18 |
# File 'lib/kempelen/API/operations/create_hit.rb', line 16 def title @title end |
#unique_request_token ⇒ Object
Returns the value of attribute unique_request_token.
11 12 13 |
# File 'lib/kempelen/API/operations/create_hit.rb', line 11 def unique_request_token @unique_request_token end |
Instance Method Details
#add_layout_parameter(name, value) ⇒ Object
47 48 49 |
# File 'lib/kempelen/API/operations/create_hit.rb', line 47 def add_layout_parameter(name, value) @layout_parameters << {Name: name, Value: value} end |
#create_parameters ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/kempelen/API/operations/create_hit.rb', line 51 def create_parameters @parameters[:operation] = AWS_OPERATION_NAME if @hit_type_id.nil? @parameters[:assignment_duration] = @assignment_duration @parameters[:auto_approval_delay] = @auto_approval_delay @parameters[:title] = @title @parameters[:description] = @description @parameters[:keywords] = @keywords @parameters[:reward_amount] = [{Amount: @reward_amount, CurrencyCode: @currency_code}] @parameters[:qualification_requirements] = @qualification_requirements unless @qualification_requirements.empty? else @parameters[:hit_type_id] = @hit_type_id end @parameters[:lifetime_in_seconds] = @lifetime_in_seconds @parameters[:max_assignments] = @max_assignments @parameters[:layout_id] = @layout_id unless @layout_id.nil? @parameters[:layout_parameters] = @layout_parameters unless @layout_parameters.empty? @parameters[:requester_annotation] = @requester_annotation unless @requester_annotation.nil? @parameters[:unique_request_token] = @unique_request_token unless @unique_request_token.nil? super end |
#perform_operation ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/kempelen/API/operations/create_hit.rb', line 75 def perform_operation create_request_string super Kempelen::API::Responses::HitResponse.new(@raw_response) end |