Class: GfreshPoint::RequestObjects::ConsumePointRequest

Inherits:
RequestObject
  • Object
show all
Defined in:
lib/gfresh_point/request_objects/consume_point_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from RequestObject

#add_error, #errors, #has_errors, #success?

Constructor Details

#initialize(app_id, user_id, point, event_name, origin_id, force, comment) ⇒ ConsumePointRequest

Returns a new instance of ConsumePointRequest.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gfresh_point/request_objects/consume_point_request.rb', line 6

def initialize(app_id, user_id, point, event_name, origin_id, force, comment)
  @app_id = app_id
  @user_id = user_id
  @point = point
  @event_name = event_name
  @origin_id = origin_id
  @comment = comment
  @force = force

  if app_id.blank?
    add_error('app_id', "App id can not be blank")
  end
  if user_id.blank?
    add_error('user_id', "User id can not be blank")
  end
  if point.blank?
    add_error('point', "point can not be blank")
  elsif point < 0
    add_error('point', "point must larger than 0")
  end
end

Instance Attribute Details

#app_idObject

Returns the value of attribute app_id.



4
5
6
# File 'lib/gfresh_point/request_objects/consume_point_request.rb', line 4

def app_id
  @app_id
end

#commentObject

Returns the value of attribute comment.



4
5
6
# File 'lib/gfresh_point/request_objects/consume_point_request.rb', line 4

def comment
  @comment
end

#event_nameObject

Returns the value of attribute event_name.



4
5
6
# File 'lib/gfresh_point/request_objects/consume_point_request.rb', line 4

def event_name
  @event_name
end

#forceObject

Returns the value of attribute force.



4
5
6
# File 'lib/gfresh_point/request_objects/consume_point_request.rb', line 4

def force
  @force
end

#origin_idObject

Returns the value of attribute origin_id.



4
5
6
# File 'lib/gfresh_point/request_objects/consume_point_request.rb', line 4

def origin_id
  @origin_id
end

#pointObject

Returns the value of attribute point.



4
5
6
# File 'lib/gfresh_point/request_objects/consume_point_request.rb', line 4

def point
  @point
end

#user_idObject

Returns the value of attribute user_id.



4
5
6
# File 'lib/gfresh_point/request_objects/consume_point_request.rb', line 4

def user_id
  @user_id
end