Advertisement
Guest User

Untitled

a guest
Jun 27th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 26.20 KB | None | 0 0
  1. Przed edycją
  2. # CRMService API Documentation - basic
  3.  
  4. # Index
  5. - [People](#people)
  6.   - [List](#list-all-people)
  7.   - [Show](#show-a-person)
  8.   - [Create](#create-a-new-person)
  9.   - [Update](#update-a-person)
  10.   - [Delete](#delete-a-person)
  11. - [Companies](#companies)
  12.   - [List](#list-all-companies)
  13.   - [Show](#show-a-company)
  14.   - [Create](#create-a-new-company)
  15.   - [Update](#update-a-company)
  16.   - [Delete](#delete-a-company)
  17. - [Custom field definitions](#custom-field-definitions)
  18.   - [List](#list-all-custom-field-definitions)
  19.   - [Show](#show-a-custom-field-definition)
  20.   - [Create](#create-a-new-custom-field-definition)
  21.   - [Update](#update-a-custom-field-definition)
  22.   - [Delete](#delete-a-custom-field-definition)
  23.   - [Change order](#change-custom-field-definitions-order)
  24. - [Custom field groups](#custom-field-groups)
  25.   - [List](#list-all-custom-field-groups)
  26.   - [Show](#show-a-custom-field-group)
  27.   - [Create](#create-a-new-custom-field-group)
  28.   - [Update](#update-a-custom-field-group)
  29.   - [Delete](#delete-a-custom-field-group)
  30.   - [Change order](#change-custom-field-groups-order)
  31.  
  32. # People
  33.  
  34. ## List all people
  35.  
  36. Shows a list of all people.
  37.  
  38. ```
  39. GET /api/v1/people
  40. ```
  41.  
  42. Example request:
  43.  
  44. ```
  45. GET /api/v1/people
  46. ```
  47.  
  48. Example response:
  49.  
  50. ```json
  51. {
  52.   "jsonapi": {
  53.      "version": "1.0",
  54.      "build": "build-id-1"
  55.   },
  56.   "data": [
  57.      {
  58.         "id": 3,
  59.         "addresses": [
  60.            {
  61.               "id": 1,
  62.               "street": "Żurawia 71",
  63.               "zipCode": "15-540",
  64.               "city": "Białystok",
  65.               "region": "woj. podlaskie",
  66.               "country": "Polska"
  67.            }
  68.         ],
  69.         "contacts":[
  70.            {
  71.               "id": 1,
  72.               "email": "shookai@gmail.com",
  73.               "phone": "123456789",
  74.               "www": "www.shookai.com"
  75.            }
  76.         ],
  77.         "company": {
  78.            "id": 1,
  79.            "name": "PULSAR ENERGY"
  80.         },
  81.         "firstName": "Karol",
  82.         "lastName": "Struk",
  83.         "position": "Web developer"
  84.      }
  85.   ]
  86. }
  87. ```
  88.  
  89. ## Show a person
  90.  
  91. Shows a single person with supplied id.
  92.  
  93. ```
  94. GET /api/v1/people/:id
  95. ```
  96.  
  97. | Attribute     | Type    | Required | Description                  |
  98. | ------------- | ------- | -------- | ---------------------------- |
  99. | `id`      | Integer    | yes      | ID of the person |
  100.  
  101. Example request:
  102.  
  103. ```
  104. GET /api/v1/people/10
  105. ```
  106.  
  107. Example response:
  108.  
  109. ```json
  110. {
  111.   "jsonapi": {
  112.      "version": "1.0",
  113.      "build": "build-id-1"
  114.   },
  115.   "data": {
  116.      {
  117.         "id": 3,
  118.         "addresses": [
  119.            {
  120.               "id": 1,
  121.               "street": "Żurawia 71",
  122.               "zipCode": "15-540",
  123.               "city": "Białystok",
  124.               "region": "woj. podlaskie",
  125.               "country": "Polska"
  126.            }
  127.         ],
  128.         "contacts":[
  129.            {
  130.               "id": 1,
  131.               "email": "shookai@gmail.com",
  132.               "phone": "123456789",
  133.               "www": "www.shookai.com"
  134.            }
  135.         ],
  136.         "company": {
  137.            "id": 1,
  138.            "name": "PULSAR ENERGY"
  139.         },
  140.         "owner": "6532f0",
  141.         "firstName": "Karol",
  142.         "lastName": "Struk",
  143.         "position": "Web developer"
  144.      }
  145. }
  146. ```
  147.  
  148. ## Create a new person
  149.  
  150. Creates a new person along with addresses and contacts sets.
  151.  
  152. ```
  153. POST /api/v1/people
  154. ```
  155.  
  156. | Attribute     | Type    | Required | Description                  |
  157. | ------------- | ------- | -------- | ---------------------------- |
  158. | `firstName`      | String    | yes      | First name of the person |
  159. | `lastName`       | String  | yes      | Last name of the person |
  160. | `position`        | String  | no      | Position of the person       |
  161. | `addresses`        | Array  | no      | Array of hashes. Each hash contains one address' fields         |
  162. | `contacts`        | Array  | no      | Array of hashes. Each hash contains one contact's fields        |
  163. | `company`        | Hash  | no      | There are two ways to create person with company: either supply existing company's id, or pass parameters to create new        |
  164.  
  165. ### Data structures:
  166.  
  167. #### Addresses
  168.  
  169. | Attribute     | Type    | Required | Description                  |
  170. | ------------- | ------- | -------- | ---------------------------- |
  171. | `street`      | String    | no      | Street name |
  172. | `zipCode`      | String    | no      | Zip code |
  173. | `city`      | String    | no      | City |
  174. | `region`      | String    | no      | Region |
  175. | `country`      | String    | no      | Country |
  176.  
  177. #### Contacts
  178.  
  179. | Attribute     | Type    | Required | Description                  |
  180. | ------------- | ------- | -------- | ---------------------------- |
  181. | `email`      | String    | no      | Email address |
  182. | `phone`      | String    | no      | Phone number |
  183. | `www`      | String    | no      | Website |
  184.  
  185. Example request:
  186.  
  187. ```json
  188. {
  189.   "data": {
  190.      "firstName": "Karol",
  191.      "lastName": "Struk",
  192.      "position": "Web developer",
  193.      "addresses": [
  194.         {
  195.            "street": "Żurawia 71",
  196.            "zip_code": "15-540",
  197.            "city": "Białystok",
  198.            "region": "woj. podlaskie",
  199.            "country": "Polska"
  200.         }
  201.      ],
  202.      "contacts": [
  203.         {
  204.            "email": "shookai@gmail.com",
  205.            "phone": "123456789",
  206.            "www": "www.shookai.com"
  207.         }
  208.      ],
  209.      "company": {
  210.         "id": 10
  211.      }  
  212.   }
  213. }
  214. ```
  215.  
  216. Example response:
  217.  
  218. ```json
  219. {
  220.  "jsonapi": {
  221.    "version": "1.0",
  222.    "build": "build-id-1"
  223.  },
  224.  "data": {
  225.    "id": 4
  226.  }
  227. }
  228. ```
  229.  
  230. ## Update a person
  231.  
  232. Updates person's data
  233.  
  234. ```
  235. PUT /api/v1/people/:id
  236. ```
  237.  
  238. | Attribute     | Type    | Required | Description                  |
  239. | ------------- | ------- | -------- | ---------------------------- |
  240. | `id`      | Integer    | yes      | ID of the person |
  241. | `firstName`      | String    | no      | First name of the person |
  242. | `lastName`       | String  | no      | Last name of the person |
  243. | `position`        | String  | no      | Position of the person       |
  244. | `addresses`        | Array  | no      | Array of hashes. If a hash contains "id", existing address with that id will be updated. Otherwise method will create new address with supplied fields         |
  245. | `contacts`        | Array  | no      | Array of hashes. If a hash contains "id", existing contact with that id will be updated. Otherwise method will create new contact with supplied fields        |
  246. | `company`        | Hash  | no      | There are two ways to update person's company: either supply existing company's id, or pass parameters to create new        |
  247.  
  248. ### Data structures:
  249.  
  250. #### Addresses
  251.  
  252. | Attribute     | Type    | Required | Description                  |
  253. | ------------- | ------- | -------- | ---------------------------- |
  254. | `street`      | String    | no      | Street name |
  255. | `zipCode`      | String    | no      | Zip code |
  256. | `city`      | String    | no      | City |
  257. | `region`      | String    | no      | Region |
  258. | `country`      | String    | no      | Country |
  259.  
  260. #### Contacts
  261.  
  262. | Attribute     | Type    | Required | Description                  |
  263. | ------------- | ------- | -------- | ---------------------------- |
  264. | `email`      | String    | no      | Email address |
  265. | `phone`      | String    | no      | Phone number |
  266. | `www`      | String    | no      | Website |
  267.  
  268. Example request:
  269.  
  270. ```json
  271. {
  272.   "data": {
  273.      "firstName": "Karol",
  274.      "lastName": "Struk",
  275.      "position": "Web developer",
  276.      "addresses": [
  277.         {
  278.            "street": "Żurawia 71",
  279.            "zip_code": "15-540",
  280.            "city": "Białystok",
  281.            "region": "woj. podlaskie",
  282.            "country": "Polska"
  283.         }
  284.      ],
  285.      "contacts": [
  286.         {
  287.            "id": 51,
  288.            "email": "shookai@gmail.com",
  289.            "phone": "123456789",
  290.            "www": "www.shookai.com"
  291.         }
  292.      ],
  293.      "company": {
  294.         "id": 10
  295.      }
  296.   }
  297. }
  298. ```
  299.  
  300. Example response:
  301.  
  302. ```json
  303. {
  304.  "jsonapi": {
  305.    "version": "1.0",
  306.    "build": "build-id-1"
  307.  },
  308.  "data": {
  309.    "id": 4
  310.  }
  311. }
  312. ```
  313.  
  314. ## Delete a person
  315.  
  316. Deletes a person.
  317.  
  318. ```
  319. DELETE /api/v1/people/:id
  320. ```
  321.  
  322. | Attribute     | Type    | Required | Description                  |
  323. | ------------- | ------- | -------- | ---------------------------- |
  324. | `id`      | Integer    | yes      | ID of the person |
  325.  
  326. Example request:
  327.  
  328. ```
  329. DELETE /api/v1/people/10
  330. ```
  331.  
  332. Example response:
  333.  
  334. ```
  335. 204 No Content
  336. ```
  337.  
  338.  
  339. # Companies
  340.  
  341. ## List all companies
  342.  
  343. Shows a list of all companies.
  344.  
  345. ```
  346. GET /api/v1/companies
  347. ```
  348.  
  349. Example request:
  350.  
  351. ```
  352. GET /api/v1/companies
  353. ```
  354.  
  355. Example response:
  356.  
  357. ```json
  358. {
  359.   "jsonapi": {
  360.      "version": "1.0",
  361.      "build": "build-id-1"
  362.   },
  363.   "data": [
  364.      {
  365.            "id": 26,
  366.            "addresses": [
  367.                {
  368.               "id": 1,
  369.               "street": "Żurawia 71",
  370.               "zipCode": "15-540",
  371.               "city": "Białystok",
  372.               "region": "woj. podlaskie",
  373.               "country": "Polska"
  374.            }
  375.            ],
  376.            "contacts": [
  377.                {
  378.                    "id": 1,
  379.                    "email": "shookai@gmail.com",
  380.                    "phone": "1234567890",
  381.                    "www": "www.shookai.com"
  382.                }
  383.            ],
  384.            "people": [
  385.                {
  386.                    "id": 47,
  387.                    "firstName": "Karol",
  388.                    "lastName": "Struk",
  389.                    "position": "Web developer"
  390.                }
  391.            ],
  392.            "name": "Shookai sp. z o.o.",
  393.            "nip": "9662096506",
  394.            "regon": "360977180"
  395.        }
  396.   ]
  397. }
  398. ```
  399.  
  400. ## Show a company
  401.  
  402. Shows a single company with supplied id.
  403.  
  404. ```
  405. GET /api/v1/companies/:id
  406. ```
  407.  
  408. | Attribute     | Type    | Required | Description                  |
  409. | ------------- | ------- | -------- | ---------------------------- |
  410. | `id`      | Integer    | yes      | ID of the company |
  411.  
  412. Example request:
  413.  
  414. ```
  415. GET /api/v1/companies/10
  416. ```
  417.  
  418. Example response:
  419.  
  420. ```json
  421. {
  422.   "jsonapi": {
  423.      "version": "1.0",
  424.      "build": "build-id-1"
  425.   },
  426.   "data":{
  427.      "id": 37,
  428.      "addresses": [
  429.         {
  430.            "id": 1,
  431.            "street": "Żurawia 71",
  432.            "zipCode": "15-540",
  433.            "city": "Białystok",
  434.            "region": "woj. podlaskie",
  435.            "country": "Polska"
  436.         }
  437.      ],
  438.      "contacts": [
  439.         {
  440.            "id": 1,
  441.            "email": "shookai@gmail.com",
  442.            "phone": "1234567890",
  443.            "www": "www.shookai.com"
  444.         }
  445.      ],
  446.      "people": [
  447.         {
  448.            "id": 47,
  449.            "firstName": "Karol",
  450.            "lastName": "Struk",
  451.            "position": "Web developer"
  452.         }
  453.      ],
  454.      "owner": "6532f0",
  455.      "name": "Shookai sp. z o.o.",
  456.      "nip": "9662096506",
  457.      "regon": "360977180"
  458.   }
  459. }
  460. ```
  461.  
  462. ## Create a new company
  463.  
  464. Creates a new company, along with addresses and contacts sets.
  465.  
  466. ```
  467. POST /api/v1/companies
  468. ```
  469.  
  470. | Attribute     | Type    | Required | Description                  |
  471. | ------------- | ------- | -------- | ---------------------------- |
  472. | `name`      | String    | yes      | Name of the company |
  473. | `nip`       | String  | no      | NIP of the company |
  474. | `regon`        | String  | no      | REGON of the company        |
  475. | `addresses`        | Array  | no      | Array of hashes. Each hash contains one address' fields         |
  476. | `contacts`        | Array  | no      | Array of hashes. Each hash contains one contact's fields        |
  477. | `people`        | Array  | no      | Array of IDs of people belonging to the company        |
  478.  
  479. ### Data structures:
  480.  
  481. #### Addresses
  482.  
  483. | Attribute     | Type    | Required | Description                  |
  484. | ------------- | ------- | -------- | ---------------------------- |
  485. | `street`      | String    | no      | Street name |
  486. | `zipCode`      | String    | no      | Zip code |
  487. | `city`      | String    | no      | City |
  488. | `region`      | String    | no      | Region |
  489. | `country`      | String    | no      | Country |
  490.  
  491. #### Contacts
  492.  
  493. | Attribute     | Type    | Required | Description                  |
  494. | ------------- | ------- | -------- | ---------------------------- |
  495. | `email`      | String    | no      | Email address |
  496. | `phone`      | String    | no      | Phone number |
  497. | `www`      | String    | no      | Website |
  498.  
  499. Example request:
  500.  
  501. ```json
  502. {
  503.   "data": {
  504.      "nip": "9662096506",
  505.      "regon": "360977180",
  506.      "name": "Shookai sp. z o.o.",
  507.      "addresses": [
  508.         {
  509.            "street": "Żurawia 71",
  510.            "zip_code": "15-540",
  511.            "city": "Białystok",
  512.            "region": "woj. podlaskie",
  513.            "country": "Polska"
  514.         }
  515.      ],
  516.      "contacts": [
  517.         {
  518.            "email": "shookai@gmail.com",
  519.            "phone": "123456789",
  520.            "www": "www.shookai.com"
  521.         }
  522.      ],
  523.      "people": [
  524.         1, 5, 7, 12
  525.      ]
  526.   }
  527. }
  528. ```
  529.  
  530. Example response:
  531.  
  532. ```json
  533. {
  534.  "jsonapi": {
  535.    "version": "1.0",
  536.    "build": "build-id-1"
  537.  },
  538.  "data": {
  539.    "id": 4
  540.  }
  541. }
  542. ```
  543.  
  544. ## Update a company
  545.  
  546. Updates company's data
  547.  
  548. ```
  549. PUT /api/v1/companies/:id
  550. ```
  551.  
  552. | Attribute     | Type    | Required | Description                  |
  553. | ------------- | ------- | -------- | ---------------------------- |
  554. | `id`      | Integer    | yes      | ID of the company |
  555. | `name`      | String    | no      | Name of the company |
  556. | `nip`       | String  | no      | NIP of the company |
  557. | `regon`        | String  | no      | REGON of the company        |
  558. | `addresses`        | Array  | no      | Array of hashes. If a hash contains "id", existing address with that id will be updated. Otherwise method will create new address with supplied fields         |
  559. | `contacts`        | Array  | no      | Array of hashes. If a hash contains "id", existing contact with that id will be updated. Otherwise method will create new contact with supplied fields        |
  560. | `people`        | Array  | no      | Array of IDs of people belonging to the company        |
  561.  
  562. ### Data structures:
  563.  
  564. #### Addresses
  565.  
  566. | Attribute     | Type    | Required | Description                  |
  567. | ------------- | ------- | -------- | ---------------------------- |
  568. | `street`      | String    | no      | Street name |
  569. | `zipCode`      | String    | no      | Zip code |
  570. | `city`      | String    | no      | City |
  571. | `region`      | String    | no      | Region |
  572. | `country`      | String    | no      | Country |
  573.  
  574. #### Contacts
  575.  
  576. | Attribute     | Type    | Required | Description                  |
  577. | ------------- | ------- | -------- | ---------------------------- |
  578. | `email`      | String    | no      | Email address |
  579. | `phone`      | String    | no      | Phone number |
  580. | `www`      | String    | no      | Website |
  581.  
  582. Example request:
  583.  
  584. ```json
  585. {
  586.  "data": {
  587.      "nip": "9662096506",
  588.      "regon": "360977180",
  589.      "name": "Shookai sp. z o.o."
  590.  }
  591. }
  592. ```
  593.  
  594. Example response:
  595.  
  596. ```json
  597. {
  598.  "jsonapi": {
  599.    "version": "1.0",
  600.    "build": "build-id-1"
  601.  },
  602.  "data": {
  603.    "id": 4
  604.  }
  605. }
  606. ```
  607.  
  608. ## Delete a company
  609.  
  610. Deletes a company.
  611.  
  612. ```
  613. DELETE /api/v1/companies/:id
  614. ```
  615.  
  616. | Attribute     | Type    | Required | Description                  |
  617. | ------------- | ------- | -------- | ---------------------------- |
  618. | `id`      | Integer    | yes      | ID of the company |
  619.  
  620. Example request:
  621.  
  622. ```
  623. DELETE /api/v1/companies/10
  624. ```
  625.  
  626. Example response:
  627.  
  628. ```
  629. 204 No Content
  630. ```
  631.  
  632. # Custom field definitions
  633.  
  634. ## List all custom field definitions
  635.  
  636. Shows a list of all custom field definitions visible for current account.
  637.  
  638. ```
  639. GET /api/v1/custom-field-definitions
  640. ```
  641.  
  642. Example request:
  643.  
  644. ```
  645. GET /api/v1/custom-field-definitions
  646. ```
  647.  
  648. Example response:
  649.  
  650. ```json
  651. {
  652.   "jsonapi": {
  653.      "version": "1.0",
  654.      "build": "build-id-1"
  655.   },
  656.   "data": [
  657.      {
  658.            "id": 26,
  659.            "name": "name",
  660.            "fieldType": "String",
  661.            "required": true,
  662.            "fieldableType": "Company",
  663.            "group": "Accounting",
  664.            "additionalConfig": null
  665.        }
  666.   ]
  667. }
  668. ```
  669.  
  670. ## Show a custom field definition
  671.  
  672. Shows a single custom field definition with supplied id.
  673.  
  674. ```
  675. GET /api/v1/custom-field-definitions/:id
  676. ```
  677.  
  678. | Attribute     | Type    | Required | Description                  |
  679. | ------------- | ------- | -------- | ---------------------------- |
  680. | `id`      | Integer    | yes      | ID of the custom field definition |
  681.  
  682. Example request:
  683.  
  684. ```
  685. GET /api/v1/custom-field-definitions/10
  686. ```
  687.  
  688. Example response:
  689.  
  690. ```json
  691. {
  692.   "jsonapi": {
  693.      "version": "1.0",
  694.      "build": "build-id-1"
  695.   },
  696.   "data": {
  697.            "id": 26,
  698.            "name": "name",
  699.            "fieldType": "Fields::List",
  700.            "required": true,
  701.            "fieldableType": "Company",
  702.            "group": "Accounting",
  703.            "additionalConfig": {
  704.              "multiple": "true",
  705.              "options": [
  706.                ["Label1", "Value1"],
  707.                ["Label2", "Value2"],
  708.                ["Label3", "Value3"]
  709.              ]
  710.            }
  711.        }
  712. }
  713. ```
  714.  
  715. ## Create a new custom field definition
  716.  
  717. Creates a new custom field definition.
  718.  
  719. ```
  720. POST /api/v1/custom-field-definitions
  721. ```
  722.  
  723. | Attribute     | Type    | Required | Description                  |
  724. | ------------- | ------- | -------- | ---------------------------- |
  725. | `name`      | String    | yes      | Name of the field definition |
  726. | `fieldType`       | String  | yes      | Type of the field's value |
  727. | `required`        | boolean  | yes      | Information whether field is required for fieldable model        |
  728. | `group`        | Integer  | no      | ID of the group that field should belong to        |
  729. | `additionalConfig`        | Hash  | no      | Holds select field options. Boolean "multiple" defines whether choosing multiple options should be allowed. Required only if field definition is of "Fields::List" type.        |
  730.  
  731. Example request:
  732.  
  733. ```json
  734. {
  735.   "data": {
  736.            "name": "Select field",
  737.            "fieldType": "Fields::List",
  738.            "required": true,
  739.            "group": 1,
  740.            "additionalConfig": {
  741.              "multiple": "true",
  742.              "options": [
  743.                ["Label1", "Value1"],
  744.                ["Label2", "Value2"],
  745.                ["Label3", "Value3"]
  746.              ]
  747.            }
  748.        }
  749. }
  750. ```
  751.  
  752. Example response:
  753.  
  754. ```json
  755. {
  756.  "jsonapi": {
  757.    "version": "1.0",
  758.    "build": "build-id-1"
  759.  },
  760.  "data": {
  761.    "id": 4
  762.  }
  763. }
  764. ```
  765.  
  766. ## Update a custom field definition
  767.  
  768. Updates custom field definition's data
  769.  
  770. ```
  771. PUT /api/v1/custom-field-definitions/:id
  772. ```
  773.  
  774. | Attribute     | Type    | Required | Description                  |
  775. | ------------- | ------- | -------- | ---------------------------- |
  776. | `id`      | Integer    | yes      | ID of the custom field definition |
  777. | `name`      | String    | no      | Name of the field definition |
  778. | `fieldType`       | String  | no      | Type of the field's value |
  779. | `required`        | boolean  | no      | Information whether field is required for model        |
  780. | `group`        | Integer  | no      | ID of the group that field should belong to        |
  781. | `additionalConfig`        | Hash  | no      | Holds select field options. Boolean "multiple" defines whether choosing multiple options should be allowed. Required only if field definition is of "Fields::List" type.        |
  782.  
  783. Example request:
  784.  
  785. ```json
  786. {
  787.  "data": {
  788.            "name": "name",
  789.            "fieldType": "String",
  790.            "required": true,
  791.            "group": 1
  792.        }
  793. }
  794. ```
  795.  
  796. Example response:
  797.  
  798. ```json
  799. {
  800.  "jsonapi": {
  801.    "version": "1.0",
  802.    "build": "build-id-1"
  803.  },
  804.  "data": {
  805.    "id": 4
  806.  }
  807. }
  808. ```
  809.  
  810. ## Delete a custom field definition
  811.  
  812. Deletes a custom field definition.
  813.  
  814. ```
  815. DELETE /api/v1/custom-field-definitions/:id
  816. ```
  817.  
  818. | Attribute     | Type    | Required | Description                  |
  819. | ------------- | ------- | -------- | ---------------------------- |
  820. | `id`      | Integer    | yes      | ID of the custom field definition |
  821.  
  822. Example request:
  823.  
  824. ```
  825. DELETE /api/v1/custom-field-definitions/10
  826. ```
  827.  
  828. Example response:
  829.  
  830. ```
  831. 204 No Content
  832. ```
  833.  
  834. ## Change custom field definitions order
  835.  
  836. Change an order of custom field definitions within group to be displayed in forms and show views.
  837.  
  838. ```
  839. POST /api/v1/custom-field-definitions/change-order
  840. ```
  841.  
  842. | Attribute     | Type    | Required | Description                  |
  843. | ------------- | ------- | -------- | ---------------------------- |
  844. | `order`      | Hash    | no      | Hash describing order of fields definitions within groups. Keys are groups' ids and values are arrays of definitions' ids in proper order |
  845.  
  846. Example request:
  847.  
  848. ```json
  849. {
  850.   "data": {
  851.            "order": {
  852.              "1": [4,3,5,2,1],
  853.              "3": [4,3,5,2,1],
  854.            }
  855.        }
  856. }
  857. ```
  858.  
  859. Example response:
  860.  
  861. ```
  862. 200 OK
  863. ```
  864.  
  865. # Custom field groups
  866.  
  867. ## List all custom field groups
  868.  
  869. Shows a list of all custom field groups visible for current account.
  870.  
  871. ```
  872. GET /api/v1/custom-field-groups
  873. ```
  874.  
  875. Example request:
  876.  
  877. ```
  878. GET /api/v1/custom-field-groups
  879. ```
  880.  
  881. Example response:
  882.  
  883. ```json
  884. {
  885.   "jsonapi": {
  886.      "version": "1.0",
  887.      "build": "build-id-1"
  888.   },
  889.   "data": [
  890.      {
  891.            "id": 26,
  892.            "name": "Accounting",
  893.            "fieldableType": "Person",
  894.            "orderedBy": 1,
  895.            "customFieldDefinitions": [
  896.              {
  897.                "name": "phone",
  898.                "fieldType": "String",
  899.                "required": false
  900.              }
  901.            ],
  902.            "accessRoles": [
  903.              {
  904.                "name": "role 1",
  905.                "uniq_code": "abc123"
  906.              }
  907.            ]
  908.        }
  909.   ]
  910. }
  911. ```
  912.  
  913. ## Show a custom field group
  914.  
  915. Shows a single custom field group with supplied id.
  916.  
  917. ```
  918. GET /api/v1/custom-field-groups/:id
  919. ```
  920.  
  921. | Attribute     | Type    | Required | Description                  |
  922. | ------------- | ------- | -------- | ---------------------------- |
  923. | `id`      | Integer    | yes      | ID of the custom field group |
  924.  
  925. Example request:
  926.  
  927. ```
  928. GET /api/v1/custom-field-groups/10
  929. ```
  930.  
  931. Example response:
  932.  
  933. ```json
  934. {
  935.   "jsonapi": {
  936.      "version": "1.0",
  937.      "build": "build-id-1"
  938.   },
  939.   "data": {
  940.            "id": 10,
  941.            "name": "Accounting",
  942.            "fieldableType": "Person",
  943.            "orderedBy": 1,
  944.            "customFieldDefinitions": [
  945.              {
  946.                "name": "phone",
  947.                "fieldType": "String",
  948.                "required": false
  949.              }
  950.            ],
  951.            "accessRoles": [
  952.              {
  953.                "name": "role 1",
  954.                "uniq_code": "acb123"
  955.              }
  956.            ]
  957.        }
  958. }
  959. ```
  960.  
  961. ## Create a new custom field group
  962.  
  963. Creates a new custom field group.
  964.  
  965. ```
  966. POST /api/v1/custom-field-group
  967. ```
  968.  
  969. | Attribute     | Type    | Required | Description                  |
  970. | ------------- | ------- | -------- | ---------------------------- |
  971. | `name`      | String    | yes      | Name of the field group |
  972. | `fieldableType`      | String    | yes      | Name of the model to which group should be assigned |
  973. | `accessRoles`      | Array    | yes      | Array of access roles' ids |
  974.  
  975. Example request:
  976.  
  977. ```json
  978. {
  979.   "data": {
  980.            "name": "Accounting",
  981.            "fieldableType": "Person",
  982.            "accessRoles": [1,2,3]
  983.        }
  984. }
  985. ```
  986.  
  987. Example response:
  988.  
  989. ```json
  990. {
  991.  "jsonapi": {
  992.    "version": "1.0",
  993.    "build": "build-id-1"
  994.  },
  995.  "data": {
  996.    "id": 4
  997.  }
  998. }
  999. ```
  1000.  
  1001. ## Update a custom field group
  1002.  
  1003. Updates custom field group's data
  1004.  
  1005. ```
  1006. PUT /api/v1/custom-field-groups/:id
  1007. ```
  1008.  
  1009. | Attribute     | Type    | Required | Description                  |
  1010. | ------------- | ------- | -------- | ---------------------------- |
  1011. | `id`      | Integer    | yes      | ID of the custom field group |
  1012. | `name`      | String    | no      | Name of the field group |
  1013. | `fieldableType`      | String    | yes      | Name of the model to which group should be assigned |
  1014. | `accessRoles`      | Array    | yes      | Array of access roles' ids |
  1015.  
  1016. Example request:
  1017.  
  1018. ```json
  1019. {
  1020.   "data": {
  1021.            "name": "Accounting",
  1022.            "fieldableType": "Person",
  1023.            "accessRoles": [1,2,3]
  1024.        }
  1025. }
  1026. ```
  1027.  
  1028. Example response:
  1029.  
  1030. ```json
  1031. {
  1032.  "jsonapi": {
  1033.    "version": "1.0",
  1034.    "build": "build-id-1"
  1035.  },
  1036.  "data": {
  1037.    "id": 4
  1038.  }
  1039. }
  1040. ```
  1041.  
  1042. ## Delete a custom field group
  1043.  
  1044. Deletes a custom field group.
  1045.  
  1046. ```
  1047. DELETE /api/v1/custom-field-groups/:id
  1048. ```
  1049.  
  1050. | Attribute     | Type    | Required | Description                  |
  1051. | ------------- | ------- | -------- | ---------------------------- |
  1052. | `id`      | Integer    | yes      | ID of the custom field group |
  1053.  
  1054. Example request:
  1055.  
  1056. ```
  1057. DELETE /api/v1/custom-field-groups/10
  1058. ```
  1059.  
  1060. Example response:
  1061.  
  1062. ```
  1063. 204 No Content
  1064. ```
  1065.  
  1066. ## Change custom field groups order
  1067.  
  1068. Change an order of custom field groups to be displayed in forms and show views.
  1069.  
  1070. ```
  1071. POST /api/v1/custom-field-groups/change-order
  1072. ```
  1073.  
  1074. | Attribute     | Type    | Required | Description                  |
  1075. | ------------- | ------- | -------- | ---------------------------- |
  1076. | `company`      | Array    | no      | Array of groups ids in correct order. Groups related to Company model |
  1077. | `person`      | Array    | no      | Array of groups ids in correct order. Groups related to Person model |
  1078. | `address`      | Array    | no      | Array of groups ids in correct order. Groups related to Address model |
  1079. | `contact`      | Array    | no      | Array of groups ids in correct order. Groups related to Contact model |
  1080.  
  1081. Example request:
  1082.  
  1083. ```json
  1084. {
  1085.   "data": {
  1086.            "company": [3,4,2,1],
  1087.            "person": [1,2,3,4],
  1088.            "address": [2,4,3,1],
  1089.            "contact": [1,4,2,3]
  1090.        }
  1091. }
  1092. ```
  1093.  
  1094. Example response:
  1095.  
  1096. ```
  1097. 200 OK
  1098. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement