Class: GfreshPoint::Client
- Inherits:
-
Object
- Object
- GfreshPoint::Client
- Defined in:
- lib/gfresh_point.rb
Instance Attribute Summary collapse
-
#app_id ⇒ Object
readonly
Returns the value of attribute app_id.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
Class Method Summary collapse
Instance Method Summary collapse
- #consume_point(user_id, point, event_name, origin_id, force, comment = {}) ⇒ Object
- #earn_point(user_id, event_name, origin_id = nil, comment = {}) ⇒ Object
- #fetch_user_points(user_id, event_names = [], origin_id = nil) ⇒ Object
-
#initialize(app_id, repo = GfreshPoint::Repository::ActiveRecordRepo.new) ⇒ Client
constructor
A new instance of Client.
- #list_rules ⇒ Object
- #list_user_points(user_id, event_name = nil, origin_id = nil) ⇒ Object
- #update_rule_point(rule_id, point, name = nil) ⇒ Object
Constructor Details
#initialize(app_id, repo = GfreshPoint::Repository::ActiveRecordRepo.new) ⇒ Client
Returns a new instance of Client.
33 34 35 36 |
# File 'lib/gfresh_point.rb', line 33 def initialize(app_id, repo = GfreshPoint::Repository::ActiveRecordRepo.new) @app_id = app_id @repo = repo end |
Instance Attribute Details
#app_id ⇒ Object (readonly)
Returns the value of attribute app_id.
32 33 34 |
# File 'lib/gfresh_point.rb', line 32 def app_id @app_id end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
32 33 34 |
# File 'lib/gfresh_point.rb', line 32 def repo @repo end |
Class Method Details
.do_after_create_callback(balance) ⇒ Object
80 81 82 83 84 |
# File 'lib/gfresh_point.rb', line 80 def self.do_after_create_callback(balance) # binding.pry # default blank end |
Instance Method Details
#consume_point(user_id, point, event_name, origin_id, force, comment = {}) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/gfresh_point.rb', line 52 def consume_point(user_id, point, event_name, origin_id, force, comment = {}) request = GfreshPoint::RequestObjects::ConsumePointRequest.new(app_id, user_id, point, event_name, origin_id, force, comment) use_case = GfreshPoint::Usecase::ConsumePointUsecase.new(repo) response = use_case.call(request) response end |
#earn_point(user_id, event_name, origin_id = nil, comment = {}) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/gfresh_point.rb', line 59 def earn_point(user_id, event_name, origin_id = nil, comment = {}) request = GfreshPoint::RequestObjects::EarnPointRequest.new(app_id, user_id, event_name, origin_id, comment) use_case = GfreshPoint::Usecase::EarnPointUsecase.new(repo) response = use_case.call(request) response end |
#fetch_user_points(user_id, event_names = [], origin_id = nil) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/gfresh_point.rb', line 73 def fetch_user_points(user_id, event_names = [], origin_id = nil) request = GfreshPoint::RequestObjects::FetchUserPointsRequest.new(app_id, user_id, event_names, origin_id) use_case = GfreshPoint::Usecase::FetchUserPointsUsecase.new(repo) response = use_case.call(request) response end |
#list_rules ⇒ Object
38 39 40 41 42 43 |
# File 'lib/gfresh_point.rb', line 38 def list_rules request = GfreshPoint::RequestObjects::RuleListRequest.new(filters: {app_id: app_id}) use_case = GfreshPoint::Usecase::RuleListUsecase.new(repo) response = use_case.call(request) response end |
#list_user_points(user_id, event_name = nil, origin_id = nil) ⇒ Object
66 67 68 69 70 71 |
# File 'lib/gfresh_point.rb', line 66 def list_user_points(user_id, event_name = nil, origin_id = nil) request = GfreshPoint::RequestObjects::ListUserPointsRequest.new(app_id, user_id, event_name, origin_id) use_case = GfreshPoint::Usecase::ListUserPointsUsecase.new(repo) response = use_case.call(request) response end |
#update_rule_point(rule_id, point, name = nil) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/gfresh_point.rb', line 45 def update_rule_point(rule_id, point, name = nil) request = GfreshPoint::RequestObjects::UpdateRulePointRequest.new(app_id, rule_id, point, name) use_case = GfreshPoint::Usecase::UpdateRulePointUsecase.new(repo) response = use_case.call(request) response end |