Guest User

Untitled

a guest
Oct 16th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. public Result processRecurring(Context context, RecurOrderJSON recurOrderJSON) {
  2. String id = recurOrderJSON.id;
  3. String event_type = recurOrderJSON.event_type;
  4. String request_id = recurOrderJSON.request_id;
  5. //Map data = recurOrderJSON.data;
  6. //recurringRouter(event_type, data);
  7. log.info("ID value");
  8. log.info(id);
  9.  
  10. return JsonResponse.build()
  11. .message("OK")
  12. .toResult();
  13. }
  14.  
  15. public class RecurOrderJSON {
  16.  
  17. public String id;
  18. public String event_type;
  19. public String request_id;
  20. // Maybe switch data type?
  21. //public Map data;
  22. }
  23.  
  24. router.POST().route("/recurring").with(RecurringController::processRecurring);
  25.  
  26. If you send that JSON to your application via the HTTP body you only need to add the POJO class to the controller method and Ninja will parse the incoming JSON for you:
  27.  
  28. package controllers;
  29.  
  30. public class ApplicationController {
  31.  
  32. public Result parsePerson(Person person) {
  33.  
  34. String nameOfPerson = person.name; // will be John Johnson
  35. ...
  36.  
  37. }
  38. }
  39.  
  40. {
  41. "id": "hook-XXXXX",
  42. "event_type": "tx-pending",
  43. "data": {
  44. "button_id": "static",
  45. "publisher_organization": "org-XXXXXXX",
  46. "campaign_id": "camp-097714a40aaf8965",
  47. "currency": "USD",
  48. "order_currency": "USD",
  49. "id": "tx-XXXXXXX",
  50. "category": "new-user-order",
  51. "modified_date": "2018-10-15T05:41:12.577Z",
  52. "order_total": 9680,
  53. "button_order_id": "btnorder-77c9e56fd990f127",
  54. "publisher_customer_id": "XymEz8GO2M",
  55. "rate_card_id": "ratecard-41480b2a6b1196a7",
  56. "advertising_id": null,
  57. "event_date": "2018-10-15T05:41:06Z",
  58. "status": "pending",
  59. "pub_ref": null,
  60. "account_id": "acc-4b17f5a014d0de1a",
  61. "btn_ref": "srctok-0adf9e958510b3f1",
  62. "order_id": null,
  63. "posting_rule_id": null,
  64. "order_line_items": [
  65. {
  66. "identifier": "Antique Trading Card",
  67. "description": "Includes Lifetime Warranty",
  68. "amount": 9680,
  69. "publisher_commission": 968,
  70. "attributes": {},
  71. "total": 9680,
  72. "quantity": 1
  73. }
  74. ],
  75. "order_click_channel": "webview",
  76. "order_purchase_date": null,
  77. "validated_date": null,
  78. "amount": 968,
  79. "customer_order_id": null,
  80. "created_date": "2018-10-15T05:41:12.577Z",
  81. "commerce_organization": "org-XXXXXX"
  82. },
  83. "request_id": "attempt-XXXXXXX"
  84. }
Add Comment
Please, Sign In to add comment