9 #ifndef INCLUDE_FUNAPI_MANAGEMENT_DEPLOY_API_SERVICE_H_ 10 #define INCLUDE_FUNAPI_MANAGEMENT_DEPLOY_API_SERVICE_H_ 13 #include <boost/function.hpp> 14 #include <boost/noncopyable.hpp> 15 #include <boost/regex.hpp> 16 #include <boost/shared_ptr.hpp> 17 #include <boost/variant.hpp> 61 kMissionPeriodDaily = 0,
62 kMissionPeriodWeekly = 1,
63 kMissionPeriodMonthly = 2,
67 kMissionTypeNormal = 0,
68 kMissionTypeAchievement = 1,
80 :
private boost::noncopyable {
93 virtual void GetUserSearchConditions(
94 const Ptr<StringVectorResponseWriter> &writer)
const;
97 virtual void SearchUsers(
98 const std::string &condition_name,
99 const std::string &condition_value,
101 const Ptr<JsonVectorResponseWriter> &writer)
const;
105 virtual void GetUser(
106 const std::string &
id,
107 const Ptr<JsonResponseWriter> &writer)
const;
110 virtual void UpdateUser(
111 const std::string &
id,
112 const std::string &field,
113 const std::string &value,
114 const Ptr<VoidResponseWriter> &writer)
const;
117 virtual void IsLoggedIn(
118 const std::string &key,
119 const Ptr<BoolResponseWriter> &writer)
const;
122 virtual void ForceLogout(
123 const std::string &
id,
124 const Ptr<VoidResponseWriter> &writer)
const;
130 std::string description;
135 std::string description;
138 virtual void GetUserBanned(
139 const std::string &key,
140 const Ptr<BoolResponseWriter> &writer)
const;
142 DEPRECATED(
virtual void BanUser(
143 const std::string &key,
const Ptr<VoidResponseWriter> &writer)
const);
145 virtual void BanUsers(
146 const std::vector<std::string> &user_ids,
147 const Ptr<BanUsersResponseWriter> &writer)
const;
149 DEPRECATED(
virtual void UnbanUser(
150 const std::string &key,
const Ptr<VoidResponseWriter> &writer)
const);
152 virtual void UnbanUsers(
153 const std::vector<std::string> &user_ids,
154 const Ptr<UnbanUsersResponseWriter> &writer)
const;
159 virtual void GetCharacters(
160 const std::string &user_id,
161 const Ptr<JsonVectorResponseWriter> &writer)
const;
163 virtual void GetCharacter(
164 const std::string &character_id,
165 const Ptr<JsonResponseWriter> &writer)
const;
167 virtual void UpdateCharacter(
168 const std::string &character_id,
169 const std::string &field,
170 const std::string &value,
171 const Ptr<VoidResponseWriter> &writer)
const;
174 typedef std::vector<std::pair<std::string, std::vector<std::string> > >
176 virtual void GetCharacterInventoryInfo(
177 const std::string &character_id,
181 virtual void GetInventory(
182 const std::string &type,
183 const std::string &inventory_id,
185 const Ptr<JsonVectorResponseWriter> &writer)
const;
190 virtual void DeleteInventoryItem(
191 const std::string &inventory_type,
192 const std::string &inventory_id,
193 const std::string &item_id,
194 const int64_t expected_item_quantity,
195 const int64_t quantity_to_reclaim,
196 const Ptr<VoidResponseWriter> &writer)
const;
201 int64_t expected_item_quantity;
202 int64_t quantity_to_reclaim;
205 std::string inventory_type;
206 std::string inventory_id;
207 std::vector<ReclaimedItem> reclaimed;
210 virtual void DeleteMultipleInventoryItems(
211 const std::vector<ReclaimInfo> &reclaimed,
212 const Ptr<VoidResponseWriter> &writer)
const;
215 virtual void GiveGift(
216 const std::string &target_type,
217 const std::string &title,
218 const std::string &content,
219 const fun::WallClock::Value &expires,
220 const std::vector<std::pair<std::string, uint64_t> > &items,
221 const std::vector<std::string> &users,
222 const Ptr<VoidResponseWriter> &writer)
const;
225 virtual void GiveGiftToAll(
226 const std::string &target_type,
227 const std::string &title,
228 const std::string &content,
229 const fun::WallClock::Value &expires,
230 const std::vector<std::pair<std::string, uint64_t> > &items,
231 const Ptr<VoidResponseWriter> &writer)
const;
238 const std::string &receipt_id,
240 const Ptr<VoidResponseWriter> &writer)
const;
244 std::string language_code;
247 virtual void SendRealtimeNotice(
248 const std::string &category,
249 const std::string &color,
250 const std::vector<NoticeMessage> &messages,
251 const Ptr<VoidResponseWriter> &writer)
const;
255 virtual void GetCharacterPeriodicMissionStatus(
256 const std::string &character_id,
257 MissionPeriod period,
258 const fun::WallClock::Value &start_date,
260 const Ptr<JsonVectorResponseWriter> &writer)
const;
267 virtual void GetCharacterMissionStatus(
268 const std::string &character_id,
269 MissionType mission_type,
270 const std::string &category,
271 const std::string &search_condition,
272 const std::string &search_keryword,
275 const Ptr<JsonVectorResponseWriter> &writer)
const;
282 static bool SetEditableFieldsForUser(
283 const std::vector<std::string> &field_list);
284 static bool SetEditableFieldsForCharacter(
285 const std::vector<std::string> &field_list);
289 static bool SetGiftableItems(
290 const std::vector<std::pair<std::string, std::string> > &item_list);
294 static bool SetRealtimeNoticeCategory(
295 const std::vector<std::string> &category);
298 static bool SetMissionCategory(
299 const std::vector<std::string> &normal_mission_category,
300 const std::vector<std::string> &achievement_mission_category);
314 ValueType value_type;
319 std::vector<CampaignRewardSchema> reward_schemas;
326 std::string description;
333 typedef boost::variant<int64_t, double, std::string> Value;
337 std::vector<std::pair<std::string, Value> > values;
339 fun::WallClock::Value begin_ts;
340 fun::WallClock::Value end_ts;
348 std::vector<boost::date_time::weekdays> days_of_the_week;
350 int32_t begin_ts_of_day;
351 int32_t end_ts_of_day;
353 std::string timezone;
354 } recurring_schedule;
357 typedef boost::function<bool (
const Campaign & ,
358 const std::string & ,
const std::string & ,
361 typedef boost::function<bool (
const Campaign & ,
362 const std::string & ,
const std::string & )>
365 typedef boost::function<bool (
const Campaign &campaign_type,
366 const std::string &type,
const std::string &
id)>
367 CancelCampaignCallback;
369 static bool RegisterCampaignType(
const std::string &campaign_id,
372 static void RegisterBeginCampaignCallback(
const BeginCampaignCallback &cb);
375 static void RegisterEndCampaignCallback(
const EndCampaignCallback &cb);
378 static void RegisterCancelCampaignCallback(
const CancelCampaignCallback &cb);
383 template <
typename T>
384 static void RegisterDeployApiHandler(boost::shared_ptr<T> handler);
387 struct FUNAPI_DLL_VISIBILITY
ExtraData : boost::noncopyable {
388 static Ptr<ExtraData> Create();
397 virtual bool SetDropdownList(
398 const std::string &name,
const std::vector<std::string> &values) = 0;
412 typedef boost::function<void (
418 static void RegisterCustomQueryHandler(
419 const std::string &name,
421 const std::string &uri,
423 const std::vector<std::string> &request_fields,
426 const std::vector<std::string> &response_fields,
427 const CustomApiHandler &handler,
430 const Ptr<ExtraData> &extra_data);
432 static void RegisterCustomQueryHandler(
433 const std::string &name,
435 const std::string &uri,
437 const std::vector<std::string> &request_fields,
440 const std::vector<std::string> &response_fields,
441 const CustomApiHandler &handler,
450 static void _AddImplementedHandler(
const std::string &account_handler_name);
451 static void _DoRegister(boost::shared_ptr<DeployApiHandlerBase> handler);
466 #define HAS_MEMBER_FUNCTION(NAME, ARGS) \ 467 template <typename T> \ 468 class Has ## NAME { \ 473 template <typename U, U> struct Same; \ 474 template <typename C> static Yes& Test(Same< \ 475 void (C::*)ARGS const, &C:: NAME>*); \ 476 template <typename> static No& Test(...); \ 479 static bool const value = sizeof(Test<T>(0)) == sizeof(Yes); \ 483 #define CHECK_MEMBER_FUNCTION(NAME) \ 484 if (detail::Has ## NAME<T>::value) { _AddImplementedHandler(#NAME); } 487 HAS_MEMBER_FUNCTION(GetUserSearchConditions,
488 (
const Ptr<StringVectorResponseWriter>&));
489 HAS_MEMBER_FUNCTION(SearchUsers,
491 const Ptr<JsonVectorResponseWriter>&));
492 HAS_MEMBER_FUNCTION(GetUser,
493 (
const std::string&,
const Ptr<JsonResponseWriter>&));
494 HAS_MEMBER_FUNCTION(UpdateUser,
495 (
const std::string&,
const std::string&,
const std::string&,
496 const Ptr<VoidResponseWriter>&));
497 HAS_MEMBER_FUNCTION(IsLoggedIn,
498 (
const std::string&,
const Ptr<BoolResponseWriter>&));
499 HAS_MEMBER_FUNCTION(ForceLogout,
500 (
const std::string&,
const Ptr<VoidResponseWriter>&));
502 HAS_MEMBER_FUNCTION(GetUserBanned,
503 (
const std::string&,
const Ptr<BoolResponseWriter>&));
504 HAS_MEMBER_FUNCTION(BanUser,
505 (
const std::string&,
const Ptr<VoidResponseWriter>&));
506 HAS_MEMBER_FUNCTION(BanUsers,
507 (
const std::vector<std::string>&,
508 const Ptr<BanUsersResponseWriter>&));
509 HAS_MEMBER_FUNCTION(UnbanUser,
510 (
const std::string&,
const Ptr<VoidResponseWriter>&));
511 HAS_MEMBER_FUNCTION(UnbanUsers,
512 (
const std::vector<std::string>&,
513 const Ptr<UnbanUsersResponseWriter>&));
515 HAS_MEMBER_FUNCTION(GetCharacters,
516 (
const std::string &,
const Ptr<JsonVectorResponseWriter>&));
517 HAS_MEMBER_FUNCTION(GetCharacter,
518 (
const std::string &,
const Ptr<JsonResponseWriter>&));
519 HAS_MEMBER_FUNCTION(UpdateCharacter,
520 (
const std::string&,
const std::string&,
const std::string&,
521 const Ptr<VoidResponseWriter> &));
522 HAS_MEMBER_FUNCTION(GiveGift,
523 (
const std::string&,
const std::string&,
const std::string&,
524 const fun::WallClock::Value&,
525 const std::vector<std::pair<std::string, uint64_t> >&,
526 const std::vector<std::string>&,
527 const Ptr<VoidResponseWriter> &));
528 HAS_MEMBER_FUNCTION(GiveGiftToAll,
529 (
const std::string&,
const std::string&,
530 const fun::WallClock::Value&,
531 const std::vector<std::pair<std::string, uint64_t> >&,
532 const Ptr<VoidResponseWriter> &));
533 HAS_MEMBER_FUNCTION(GetCharacterInventoryInfo,
534 (
const std::string &,
536 DeployApiService::DeployApiHandlerBase::InventoryInfo> >&));
537 HAS_MEMBER_FUNCTION(GetInventory,
538 (
const std::string&,
const std::string &,
540 const Ptr<JsonVectorResponseWriter>&));
541 HAS_MEMBER_FUNCTION(DeleteInventoryItem,
542 (
const std::string&,
const std::string&,
const std::string &,
543 const int64_t,
const int64_t,
const Ptr<VoidResponseWriter> &));
544 HAS_MEMBER_FUNCTION(DeleteMultipleInventoryItems,
545 (
const std::vector<DeployApiService::DeployApiHandlerBase::ReclaimInfo> &,
546 const Ptr<VoidResponseWriter> &));
547 HAS_MEMBER_FUNCTION(Refund,
548 (
const std::string &,
const fun::Json &,
const Ptr<VoidResponseWriter> &));
549 HAS_MEMBER_FUNCTION(SendRealtimeNotice,
550 (
const std::string &,
552 const std::vector<DeployApiService::DeployApiHandlerBase::NoticeMessage>&,
553 const Ptr<VoidResponseWriter> &));
554 HAS_MEMBER_FUNCTION(GetCharacterPeriodicMissionStatus,
555 (
const std::string &, DeployApiService::MissionPeriod,
557 const Ptr<JsonVectorResponseWriter> &));
558 HAS_MEMBER_FUNCTION(GetCharacterMissionStatus,
559 (
const std::string &, DeployApiService::MissionType,
const std::string &,
560 const std::string &,
const std::string &,
bool,
562 const Ptr<JsonVectorResponseWriter> &));
569 void DeployApiService::RegisterDeployApiHandler<
571 boost::shared_ptr<DeployApiService::DeployApiHandlerBase> handler);
574 template <
typename T>
575 void DeployApiService::RegisterDeployApiHandler(boost::shared_ptr<T> handler) {
576 CHECK_MEMBER_FUNCTION(GetUserSearchConditions);
577 CHECK_MEMBER_FUNCTION(SearchUsers);
579 CHECK_MEMBER_FUNCTION(GetUser);
580 CHECK_MEMBER_FUNCTION(UpdateUser);
581 CHECK_MEMBER_FUNCTION(IsLoggedIn);
582 CHECK_MEMBER_FUNCTION(ForceLogout);
584 CHECK_MEMBER_FUNCTION(GetUserBanned);
585 CHECK_MEMBER_FUNCTION(BanUser);
586 CHECK_MEMBER_FUNCTION(BanUsers);
587 CHECK_MEMBER_FUNCTION(UnbanUser);
588 CHECK_MEMBER_FUNCTION(UnbanUsers);
590 CHECK_MEMBER_FUNCTION(GetCharacters);
591 CHECK_MEMBER_FUNCTION(GetCharacter);
592 CHECK_MEMBER_FUNCTION(UpdateCharacter);
593 CHECK_MEMBER_FUNCTION(GiveGift);
594 if (not detail::HasGiveGift<T>::value) {
595 CHECK_MEMBER_FUNCTION(GiveGiftToAll);
597 CHECK_MEMBER_FUNCTION(GetCharacterInventoryInfo);
598 CHECK_MEMBER_FUNCTION(GetInventory);
599 CHECK_MEMBER_FUNCTION(DeleteInventoryItem);
600 CHECK_MEMBER_FUNCTION(DeleteMultipleInventoryItems);
602 CHECK_MEMBER_FUNCTION(Refund);
603 CHECK_MEMBER_FUNCTION(SendRealtimeNotice);
605 CHECK_MEMBER_FUNCTION(GetCharacterPeriodicMissionStatus);
606 CHECK_MEMBER_FUNCTION(GetCharacterMissionStatus);
608 _DoRegister(
static_cast<boost::shared_ptr<DeployApiHandlerBase>
>(handler));
613 #endif // INCLUDE_FUNAPI_MANAGEMENT_DEPLOY_API_SERVICE_H_ Definition: deploy_api_service.h:198
StatusCode
Enum representing HTTP status code.
Definition: http_util.h:63
Definition: deploy_api_service.h:243
Definition: deploy_api_service.h:43
Definition: deploy_api_service.h:133
Definition: deploy_api_service.h:345
Definition: deploy_api_service.h:55
Definition: deploy_api_service.h:317
boost::function< void(const PageInfo &, const fun::Json &, Ptr< JsonResponseWriter > &)> CustomApiHandler
Custom query handlers for iFunDeploy {.
Definition: deploy_api_service.h:415
Definition: deploy_api_service.h:79
Definition: deploy_api_service.h:304
Definition: deploy_api_service.h:324
Definition: deploy_api_service.h:128
Definition: deploy_api_service.h:71
Definition: deploy_api_service.h:31
Definition: deploy_api_service.h:36
Method
Enum type representing HTTP methods.
Definition: http_util.h:34
Definition: deploy_api_service.h:199