Class: CF::HumanWorker
- Inherits:
-
Object
- Object
- CF::HumanWorker
- Extended by:
- ActiveSupport::Concern
- Includes:
- Client
- Defined in:
- lib/cf/human_worker.rb
Instance Attribute Summary (collapse)
-
- (Object) badge
Returns the value of attribute badge.
-
- (Object) errors
Returns the value of attribute errors.
-
- (Object) id
Returns the value of attribute id.
-
- (Object) number
Returns the value of attribute number.
-
- (Object) reward
Returns the value of attribute reward.
-
- (Object) skill_badges
Returns the value of attribute skill_badges.
-
- (Object) stat_badge
Returns the value of attribute stat_badge.
-
- (Object) station
Returns the value of attribute station.
Instance Method Summary (collapse)
-
- (HumanWorker) initialize(options = {})
constructor
A new instance of HumanWorker.
Constructor Details
- (HumanWorker) initialize(options = {})
A new instance of HumanWorker
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/cf/human_worker.rb', line 9 def initialize(={}) @skill_badges = [] @station = [:station] @number = [:number].nil? ? 1 : [:number] @reward = [:reward] @badge = [:skill_badge].nil? ? nil : [:skill_badge] @stat_badge = [:stat_badge].nil? ? nil : [:stat_badge] if @station if [:skill_badge].nil? && [:stat_badge].nil? request = { :body => { :api_key => CF.api_key, :worker => {:number => @number, :reward => @reward, :type => "HumanWorker"} } } else request = { :body => { :api_key => CF.api_key, :worker => {:number => @number, :reward => @reward, :type => "HumanWorker"}, :skill_badge => @badge, :stat_badge => [:stat_badge] } } end resp = HTTParty.post("#{CF.api_url}#{CF.api_version}/lines/#{CF.account_name}/#{@station.line['title'].downcase}/stations/#{@station.index}/workers.json",request) self.id = resp.parsed_response['id'] self.number = resp.parsed_response['number'] self.reward = resp.parsed_response['reward'] self.stat_badge = resp.parsed_response['stat_badge'] @skill_badges << resp.parsed_response['skill_badges'] if resp.code != 200 self.errors = resp.parsed_response['error']['message'] end self.station = [:station] self.station.worker = self end end |
Instance Attribute Details
- (Object) badge
Returns the value of attribute badge
7 8 9 |
# File 'lib/cf/human_worker.rb', line 7 def badge @badge end |
- (Object) errors
Returns the value of attribute errors
7 8 9 |
# File 'lib/cf/human_worker.rb', line 7 def errors @errors end |
- (Object) id
Returns the value of attribute id
7 8 9 |
# File 'lib/cf/human_worker.rb', line 7 def id @id end |
- (Object) number
Returns the value of attribute number
7 8 9 |
# File 'lib/cf/human_worker.rb', line 7 def number @number end |
- (Object) reward
Returns the value of attribute reward
7 8 9 |
# File 'lib/cf/human_worker.rb', line 7 def reward @reward end |
- (Object) skill_badges
Returns the value of attribute skill_badges
7 8 9 |
# File 'lib/cf/human_worker.rb', line 7 def skill_badges @skill_badges end |
- (Object) stat_badge
Returns the value of attribute stat_badge
7 8 9 |
# File 'lib/cf/human_worker.rb', line 7 def stat_badge @stat_badge end |
- (Object) station
Returns the value of attribute station
7 8 9 |
# File 'lib/cf/human_worker.rb', line 7 def station @station end |