Advertisement
Guest User

Untitled

a guest
Aug 27th, 2017
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.05 KB | None | 0 0
  1. ---
  2. openapi: '3.0.0'
  3. info:
  4. version: 0.1.0
  5. title: Lanye API demo
  6. description: |
  7. This is the API reference of the Lanye API demo.
  8.  
  9. All fields which store time like `createAt`, `updateAt` are all unix timestamp.
  10. host: lanye.test.hsexpert.net
  11. basePath: /v0
  12. schemes:
  13. - http
  14. - https
  15. paths:
  16. /user:
  17. post:
  18. consumes:
  19. - application/json
  20. produces:
  21. - application/json
  22. tags:
  23. - User
  24. summary: Add a user
  25. description: |
  26. Add a user using the user input.
  27.  
  28. You **must** fill in the following fields:
  29. * email
  30. * password
  31.  
  32. All sensitive information will be removed in response.
  33. parameters:
  34. - name: body
  35. in: body
  36. description: User information
  37. required: true
  38. schema:
  39. $ref: "#/definitions/User"
  40. responses:
  41. 201:
  42. description: OK
  43. schema:
  44. $ref: "#/definitions/User"
  45. 400:
  46. description: Invalid user information, maybe duplicate email or wrong field name / datatype. More information will be in `Error.message`
  47. schema:
  48. $ref: "#/definitions/Error"
  49.  
  50. /user/{user_id}:
  51. patch:
  52. consumes:
  53. - application/json
  54. produces:
  55. - application/json
  56. tags:
  57. - User
  58. summary: Update specified user data.
  59. description: |
  60. Update user data specified in `user_id`. This API will only replace given fields.
  61.  
  62. ** `email` cannot be modified. ** It makes no effect if you give that.
  63. parameters:
  64. - name: user_id
  65. in: path
  66. description: Unique identifier of user
  67. required: true
  68. type: integer
  69. format: int32
  70. - name: body
  71. in: body
  72. description: User information
  73. required: false
  74. schema:
  75. $ref: "#/definitions/User"
  76. responses:
  77. 200:
  78. description: OK
  79. schema:
  80. $ref: "#/definitions/User"
  81. 400:
  82. description: Invalid input, maybe undefined fields or incorrect content.
  83. schema:
  84. $ref: "#/definitions/Error"
  85. 404:
  86. description: Cannot find user given in `user_id`
  87. schema:
  88. $ref: "#/definitions/Error"
  89. security:
  90. - user_login_token: []
  91.  
  92. put:
  93. consumes:
  94. - application/json
  95. produces:
  96. - application/json
  97. tags:
  98. - User
  99. summary: Replace specified user data.
  100. description: |
  101. Update user data specified in `user_id`. This API will replace all fields with input.
  102.  
  103. ** `email` cannot be modified. ** It makes no effect if you give that.
  104. parameters:
  105. - name: user_id
  106. in: path
  107. description: Unique identifier of user
  108. required: true
  109. type: integer
  110. format: int32
  111. - name: body
  112. in: body
  113. description: User information
  114. required: false
  115. schema:
  116. $ref: "#/definitions/User"
  117. responses:
  118. 200:
  119. description: OK
  120. schema:
  121. $ref: "#/definitions/User"
  122. 400:
  123. description: Invalid input, maybe undefined fields or incorrect content.
  124. schema:
  125. $ref: "#/definitions/Error"
  126. 404:
  127. description: Cannot find user given in `user_id`
  128. schema:
  129. $ref: "#/definitions/Error"
  130. security:
  131. - user_login_token: []
  132.  
  133. delete:
  134. consumes:
  135. - application/json
  136. produces:
  137. - application/json
  138. tags:
  139. - User
  140. summary: Delete specified user.
  141. description: Delete user specified in `user_id`.
  142. parameters:
  143. - name: user_id
  144. in: path
  145. description: Unique identifier of user
  146. required: true
  147. type: integer
  148. format: int32
  149. responses:
  150. 200:
  151. description: OK
  152. schema:
  153. $ref: "#/definitions/User"
  154. 400:
  155. description: Invalid input, maybe undefined fields or incorrect content.
  156. schema:
  157. $ref: "#/definitions/Error"
  158. 404:
  159. description: Cannot find user given in `user_id`
  160. schema:
  161. $ref: "#/definitions/Error"
  162. security:
  163. - user_login_token: []
  164.  
  165. /user/now:
  166. get:
  167. consumes:
  168. - application/json
  169. produces:
  170. - application/json
  171. tags:
  172. - User
  173. summary: Get user logged in now.
  174. description: |
  175. Get the user logged in now, if user is not logged in, an 401 error will be return.
  176. responses:
  177. 200:
  178. description: OK
  179. schema:
  180. $ref: "#/definitions/User"
  181. 401:
  182. description: Not logged in.
  183. schema:
  184. $ref: "#/definitions/Error"
  185. security:
  186. - user_login_token: []
  187.  
  188. /auth/local:
  189. post:
  190. consumes:
  191. - application/json
  192. produces:
  193. - application/json
  194. tags:
  195. - Authentication
  196. summary: Authenticate to the system using email and password.
  197. description: |
  198. Authenticate to the system using `email` and `password` (`user_id` is no need.).
  199.  
  200. You have to put `token` from response in header as `authorization` when querying APIs that needs authorization.
  201. parameters:
  202. - name: body
  203. in: body
  204. description: Email and password of user
  205. required: true
  206. schema:
  207. $ref: "#/definitions/User"
  208. responses:
  209. 200:
  210. description: OK
  211. schema:
  212. $ref: "#/definitions/TokenAuthentication"
  213. 403:
  214. description: Email or password is incorrect.
  215. schema:
  216. $ref: "#/definitions/Error"
  217.  
  218.  
  219.  
  220. /device:
  221. post:
  222. consumes:
  223. - application/json
  224. produces:
  225. - application/json
  226. tags:
  227. - Device
  228. summary: Add a device
  229. description: |
  230. Add a device using the user input.
  231.  
  232. You only have to pass `user_id` and `onesignal_id` when calling this API. Other information will retrive via Onesignal API.
  233.  
  234. `user_id` is indicated to the user who own this device, but it's **NOT** required, because app needs to register the device when it started, at that time the user is not created.
  235. But it should be added later.
  236.  
  237. P.S. Device here is similar to `Device` in Onesignal, so all the fields which name is same as Onesignal Device store same data as in Onesignal.
  238. parameters:
  239. - name: body
  240. in: body
  241. description: Device information
  242. required: true
  243. schema:
  244. $ref: "#/definitions/Device"
  245. responses:
  246. 201:
  247. description: OK
  248. schema:
  249. $ref: "#/definitions/Device"
  250. 400:
  251. description: Invalid device information, maybe duplicate identifier or wrong field name / datatype. More information will be in `Error.message`
  252. schema:
  253. $ref: "#/definitions/Error"
  254. 404:
  255. description: The `identifier` or `user_id` is not found in database.
  256. schema:
  257. $ref: "#/definitions/Error"
  258.  
  259. /device/{device_id}:
  260. patch:
  261. consumes:
  262. - application/json
  263. produces:
  264. - application/json
  265. tags:
  266. - Device
  267. summary: Update specified device data.
  268. description: |
  269. Update device data specified in `device_id`. This API will only replace given fields.
  270.  
  271. parameters:
  272. - name: device_id
  273. in: path
  274. description: Unique identifier of user
  275. required: true
  276. type: integer
  277. format: int32
  278. - name: body
  279. in: body
  280. description: User information
  281. required: false
  282. schema:
  283. $ref: "#/definitions/Device"
  284. responses:
  285. 200:
  286. description: OK
  287. schema:
  288. $ref: "#/definitions/Device"
  289. 400:
  290. description: Invalid input, maybe undefined fields or incorrect content.
  291. schema:
  292. $ref: "#/definitions/Error"
  293. 404:
  294. description: Cannot find device given in `device_id`
  295. schema:
  296. $ref: "#/definitions/Error"
  297. security:
  298. - user_login_token: []
  299.  
  300. put:
  301. consumes:
  302. - application/json
  303. produces:
  304. - application/json
  305. tags:
  306. - Device
  307. summary: Replace specified device data.
  308. description: |
  309. Update device data specified in `device_id`. This API will replace all fields with input.
  310.  
  311. parameters:
  312. - name: device_id
  313. in: path
  314. description: Unique identifier of user
  315. required: true
  316. type: integer
  317. format: int32
  318. - name: body
  319. in: body
  320. description: Device information
  321. required: false
  322. schema:
  323. $ref: "#/definitions/Device"
  324. responses:
  325. 200:
  326. description: OK
  327. schema:
  328. $ref: "#/definitions/Device"
  329. 400:
  330. description: Invalid input, maybe undefined fields or incorrect content.
  331. schema:
  332. $ref: "#/definitions/Error"
  333. 404:
  334. description: Cannot find user given in `device_id`
  335. schema:
  336. $ref: "#/definitions/Error"
  337. security:
  338. - user_login_token: []
  339.  
  340. delete:
  341. consumes:
  342. - application/json
  343. produces:
  344. - application/json
  345. tags:
  346. - Device
  347. summary: Delete specified device.
  348. description: Delete device specified in `device_id`.
  349. parameters:
  350. - name: device_id
  351. in: path
  352. description: Unique identifier of device
  353. required: true
  354. type: integer
  355. format: int32
  356. responses:
  357. 200:
  358. description: OK
  359. schema:
  360. $ref: "#/definitions/Device"
  361. 400:
  362. description: Invalid input, maybe undefined fields or incorrect content.
  363. schema:
  364. $ref: "#/definitions/Error"
  365. 404:
  366. description: Cannot find device given in `device_id`
  367. schema:
  368. $ref: "#/definitions/Error"
  369. security:
  370. - user_login_token: []
  371.  
  372. /push-notification:
  373. post:
  374. tags:
  375. - Push-Notification
  376. consumes:
  377. - application/json
  378. produces:
  379. - application/json
  380. summary: Create a push notification.
  381. description: |
  382. Create a push notification send via Onesignal API.
  383.  
  384. For the fields in body, please refer to [Onesignal official API document](https://documentation.onesignal.com/reference#create-notification).
  385.  
  386. You **must** fill in the following fields:
  387. * contents
  388.  
  389. The `user_id` in `include_user_ids` is same as the `user_id` field in `User` object, and so is `device_id`.
  390.  
  391. If none of `included_segments`, `excluded_segments`, `filters`, `include_player_ids`, `include_device_ids`, `include_user_ids` are given, every device will receive push notification.
  392. parameters:
  393. - name: body
  394. in: body
  395. schema:
  396. $ref: "#/definitions/Notification"
  397. responses:
  398. 200:
  399. description: OK
  400. schema:
  401. $ref: "#/definitions/Notification"
  402. 401:
  403. description: Not logged in.
  404. schema:
  405. $ref: "#/definitions/Error"
  406. security:
  407. - user_login_token: []
  408.  
  409. /push-notification/history:
  410. get:
  411. tags:
  412. - Push-Notification
  413. consumes:
  414. - application/json
  415. produces:
  416. - application/json
  417. summary: Get push notification history list.
  418. description: |
  419. Get the list of push notification history.
  420. responses:
  421. 200:
  422. description: OK
  423. schema:
  424. type: array
  425. items:
  426. $ref: "#/definitions/Notification"
  427. security:
  428. - user_login_token: []
  429.  
  430. definitions:
  431. User:
  432. type: object
  433. required:
  434. - email
  435. properties:
  436. user_id:
  437. type: integer
  438. format: int32
  439. email:
  440. type: string
  441. format: email
  442. password:
  443. type: string
  444. format: password
  445. createAt:
  446. type: integer
  447. format: int32
  448. updateAt:
  449. type: integer
  450. format: int32
  451. devices:
  452. type: array
  453. items:
  454. $ref: "#/definitions/Device"
  455.  
  456. Error:
  457. type: object
  458. required:
  459. - name
  460. - message
  461. - code
  462. - className
  463. properties:
  464. name:
  465. type: string
  466. message:
  467. type: string
  468. code:
  469. type: integer
  470. format: int32
  471. className:
  472. type: string
  473. errors:
  474. type: object
  475.  
  476. TokenAuthentication:
  477. type: object
  478. required:
  479. - token
  480. - data
  481. properties:
  482. token:
  483. type: string
  484. data:
  485. $ref: "#/definitions/User"
  486.  
  487. Device:
  488. type: object
  489. required:
  490. - onesingal_id
  491. properties:
  492. device_id:
  493. type: integer
  494. format: int32
  495. user_id:
  496. type: integer
  497. format: int32
  498. device_type:
  499. type: integer
  500. format: int32
  501. onesingal_id:
  502. type: string
  503. identifier:
  504. type: string
  505. language:
  506. type: string
  507. timezone:
  508. type: integer
  509. game_version:
  510. type: string
  511. device_model:
  512. type: string
  513. device_os:
  514. type: string
  515. ad_id:
  516. type: string
  517. sdk:
  518. type: string
  519. createAt:
  520. type: integer
  521. format: int32
  522. updateAt:
  523. type: integer
  524. format: int32
  525.  
  526. Notification:
  527. type: object
  528. required:
  529. - contents
  530. properties:
  531. notification_id:
  532. type: integer
  533. format: int32
  534. included_segments:
  535. type: array
  536. items:
  537. type: string
  538. excluded_segments:
  539. type: array
  540. items:
  541. type: string
  542. filters:
  543. type: object
  544. include_player_ids:
  545. type: array
  546. items:
  547. type: string
  548. include_device_ids:
  549. type: array
  550. items:
  551. type: integer
  552. include_user_ids:
  553. type: array
  554. items:
  555. type: integer
  556. contents:
  557. type: object
  558. headings:
  559. type: object
  560. createAt:
  561. type: integer
  562. format: int32
  563. updateAt:
  564. type: integer
  565. format: int32
  566.  
  567. securityDefinitions:
  568. user_login_token:
  569. type: apiKey
  570. name: authorization
  571. in: header
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement