Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Przed edycją
- # CRMService API Documentation - basic
- # Index
- - [People](#people)
- - [List](#list-all-people)
- - [Show](#show-a-person)
- - [Create](#create-a-new-person)
- - [Update](#update-a-person)
- - [Delete](#delete-a-person)
- - [Companies](#companies)
- - [List](#list-all-companies)
- - [Show](#show-a-company)
- - [Create](#create-a-new-company)
- - [Update](#update-a-company)
- - [Delete](#delete-a-company)
- - [Custom field definitions](#custom-field-definitions)
- - [List](#list-all-custom-field-definitions)
- - [Show](#show-a-custom-field-definition)
- - [Create](#create-a-new-custom-field-definition)
- - [Update](#update-a-custom-field-definition)
- - [Delete](#delete-a-custom-field-definition)
- - [Change order](#change-custom-field-definitions-order)
- - [Custom field groups](#custom-field-groups)
- - [List](#list-all-custom-field-groups)
- - [Show](#show-a-custom-field-group)
- - [Create](#create-a-new-custom-field-group)
- - [Update](#update-a-custom-field-group)
- - [Delete](#delete-a-custom-field-group)
- - [Change order](#change-custom-field-groups-order)
- # People
- ## List all people
- Shows a list of all people.
- ```
- GET /api/v1/people
- ```
- Example request:
- ```
- GET /api/v1/people
- ```
- Example response:
- ```json
- {
- "jsonapi": {
- "version": "1.0",
- "build": "build-id-1"
- },
- "data": [
- {
- "id": 3,
- "addresses": [
- {
- "id": 1,
- "street": "Żurawia 71",
- "zipCode": "15-540",
- "city": "Białystok",
- "region": "woj. podlaskie",
- "country": "Polska"
- }
- ],
- "contacts":[
- {
- "id": 1,
- "email": "shookai@gmail.com",
- "phone": "123456789",
- "www": "www.shookai.com"
- }
- ],
- "company": {
- "id": 1,
- "name": "PULSAR ENERGY"
- },
- "firstName": "Karol",
- "lastName": "Struk",
- "position": "Web developer"
- }
- ]
- }
- ```
- ## Show a person
- Shows a single person with supplied id.
- ```
- GET /api/v1/people/:id
- ```
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `id` | Integer | yes | ID of the person |
- Example request:
- ```
- GET /api/v1/people/10
- ```
- Example response:
- ```json
- {
- "jsonapi": {
- "version": "1.0",
- "build": "build-id-1"
- },
- "data": {
- {
- "id": 3,
- "addresses": [
- {
- "id": 1,
- "street": "Żurawia 71",
- "zipCode": "15-540",
- "city": "Białystok",
- "region": "woj. podlaskie",
- "country": "Polska"
- }
- ],
- "contacts":[
- {
- "id": 1,
- "email": "shookai@gmail.com",
- "phone": "123456789",
- "www": "www.shookai.com"
- }
- ],
- "company": {
- "id": 1,
- "name": "PULSAR ENERGY"
- },
- "owner": "6532f0",
- "firstName": "Karol",
- "lastName": "Struk",
- "position": "Web developer"
- }
- }
- ```
- ## Create a new person
- Creates a new person along with addresses and contacts sets.
- ```
- POST /api/v1/people
- ```
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `firstName` | String | yes | First name of the person |
- | `lastName` | String | yes | Last name of the person |
- | `position` | String | no | Position of the person |
- | `addresses` | Array | no | Array of hashes. Each hash contains one address' fields |
- | `contacts` | Array | no | Array of hashes. Each hash contains one contact's fields |
- | `company` | Hash | no | There are two ways to create person with company: either supply existing company's id, or pass parameters to create new |
- ### Data structures:
- #### Addresses
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `street` | String | no | Street name |
- | `zipCode` | String | no | Zip code |
- | `city` | String | no | City |
- | `region` | String | no | Region |
- | `country` | String | no | Country |
- #### Contacts
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `email` | String | no | Email address |
- | `phone` | String | no | Phone number |
- | `www` | String | no | Website |
- Example request:
- ```json
- {
- "data": {
- "firstName": "Karol",
- "lastName": "Struk",
- "position": "Web developer",
- "addresses": [
- {
- "street": "Żurawia 71",
- "zip_code": "15-540",
- "city": "Białystok",
- "region": "woj. podlaskie",
- "country": "Polska"
- }
- ],
- "contacts": [
- {
- "email": "shookai@gmail.com",
- "phone": "123456789",
- "www": "www.shookai.com"
- }
- ],
- "company": {
- "id": 10
- }
- }
- }
- ```
- Example response:
- ```json
- {
- "jsonapi": {
- "version": "1.0",
- "build": "build-id-1"
- },
- "data": {
- "id": 4
- }
- }
- ```
- ## Update a person
- Updates person's data
- ```
- PUT /api/v1/people/:id
- ```
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `id` | Integer | yes | ID of the person |
- | `firstName` | String | no | First name of the person |
- | `lastName` | String | no | Last name of the person |
- | `position` | String | no | Position of the person |
- | `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 |
- | `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 |
- | `company` | Hash | no | There are two ways to update person's company: either supply existing company's id, or pass parameters to create new |
- ### Data structures:
- #### Addresses
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `street` | String | no | Street name |
- | `zipCode` | String | no | Zip code |
- | `city` | String | no | City |
- | `region` | String | no | Region |
- | `country` | String | no | Country |
- #### Contacts
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `email` | String | no | Email address |
- | `phone` | String | no | Phone number |
- | `www` | String | no | Website |
- Example request:
- ```json
- {
- "data": {
- "firstName": "Karol",
- "lastName": "Struk",
- "position": "Web developer",
- "addresses": [
- {
- "street": "Żurawia 71",
- "zip_code": "15-540",
- "city": "Białystok",
- "region": "woj. podlaskie",
- "country": "Polska"
- }
- ],
- "contacts": [
- {
- "id": 51,
- "email": "shookai@gmail.com",
- "phone": "123456789",
- "www": "www.shookai.com"
- }
- ],
- "company": {
- "id": 10
- }
- }
- }
- ```
- Example response:
- ```json
- {
- "jsonapi": {
- "version": "1.0",
- "build": "build-id-1"
- },
- "data": {
- "id": 4
- }
- }
- ```
- ## Delete a person
- Deletes a person.
- ```
- DELETE /api/v1/people/:id
- ```
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `id` | Integer | yes | ID of the person |
- Example request:
- ```
- DELETE /api/v1/people/10
- ```
- Example response:
- ```
- 204 No Content
- ```
- # Companies
- ## List all companies
- Shows a list of all companies.
- ```
- GET /api/v1/companies
- ```
- Example request:
- ```
- GET /api/v1/companies
- ```
- Example response:
- ```json
- {
- "jsonapi": {
- "version": "1.0",
- "build": "build-id-1"
- },
- "data": [
- {
- "id": 26,
- "addresses": [
- {
- "id": 1,
- "street": "Żurawia 71",
- "zipCode": "15-540",
- "city": "Białystok",
- "region": "woj. podlaskie",
- "country": "Polska"
- }
- ],
- "contacts": [
- {
- "id": 1,
- "email": "shookai@gmail.com",
- "phone": "1234567890",
- "www": "www.shookai.com"
- }
- ],
- "people": [
- {
- "id": 47,
- "firstName": "Karol",
- "lastName": "Struk",
- "position": "Web developer"
- }
- ],
- "name": "Shookai sp. z o.o.",
- "nip": "9662096506",
- "regon": "360977180"
- }
- ]
- }
- ```
- ## Show a company
- Shows a single company with supplied id.
- ```
- GET /api/v1/companies/:id
- ```
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `id` | Integer | yes | ID of the company |
- Example request:
- ```
- GET /api/v1/companies/10
- ```
- Example response:
- ```json
- {
- "jsonapi": {
- "version": "1.0",
- "build": "build-id-1"
- },
- "data":{
- "id": 37,
- "addresses": [
- {
- "id": 1,
- "street": "Żurawia 71",
- "zipCode": "15-540",
- "city": "Białystok",
- "region": "woj. podlaskie",
- "country": "Polska"
- }
- ],
- "contacts": [
- {
- "id": 1,
- "email": "shookai@gmail.com",
- "phone": "1234567890",
- "www": "www.shookai.com"
- }
- ],
- "people": [
- {
- "id": 47,
- "firstName": "Karol",
- "lastName": "Struk",
- "position": "Web developer"
- }
- ],
- "owner": "6532f0",
- "name": "Shookai sp. z o.o.",
- "nip": "9662096506",
- "regon": "360977180"
- }
- }
- ```
- ## Create a new company
- Creates a new company, along with addresses and contacts sets.
- ```
- POST /api/v1/companies
- ```
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `name` | String | yes | Name of the company |
- | `nip` | String | no | NIP of the company |
- | `regon` | String | no | REGON of the company |
- | `addresses` | Array | no | Array of hashes. Each hash contains one address' fields |
- | `contacts` | Array | no | Array of hashes. Each hash contains one contact's fields |
- | `people` | Array | no | Array of IDs of people belonging to the company |
- ### Data structures:
- #### Addresses
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `street` | String | no | Street name |
- | `zipCode` | String | no | Zip code |
- | `city` | String | no | City |
- | `region` | String | no | Region |
- | `country` | String | no | Country |
- #### Contacts
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `email` | String | no | Email address |
- | `phone` | String | no | Phone number |
- | `www` | String | no | Website |
- Example request:
- ```json
- {
- "data": {
- "nip": "9662096506",
- "regon": "360977180",
- "name": "Shookai sp. z o.o.",
- "addresses": [
- {
- "street": "Żurawia 71",
- "zip_code": "15-540",
- "city": "Białystok",
- "region": "woj. podlaskie",
- "country": "Polska"
- }
- ],
- "contacts": [
- {
- "email": "shookai@gmail.com",
- "phone": "123456789",
- "www": "www.shookai.com"
- }
- ],
- "people": [
- 1, 5, 7, 12
- ]
- }
- }
- ```
- Example response:
- ```json
- {
- "jsonapi": {
- "version": "1.0",
- "build": "build-id-1"
- },
- "data": {
- "id": 4
- }
- }
- ```
- ## Update a company
- Updates company's data
- ```
- PUT /api/v1/companies/:id
- ```
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `id` | Integer | yes | ID of the company |
- | `name` | String | no | Name of the company |
- | `nip` | String | no | NIP of the company |
- | `regon` | String | no | REGON of the company |
- | `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 |
- | `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 |
- | `people` | Array | no | Array of IDs of people belonging to the company |
- ### Data structures:
- #### Addresses
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `street` | String | no | Street name |
- | `zipCode` | String | no | Zip code |
- | `city` | String | no | City |
- | `region` | String | no | Region |
- | `country` | String | no | Country |
- #### Contacts
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `email` | String | no | Email address |
- | `phone` | String | no | Phone number |
- | `www` | String | no | Website |
- Example request:
- ```json
- {
- "data": {
- "nip": "9662096506",
- "regon": "360977180",
- "name": "Shookai sp. z o.o."
- }
- }
- ```
- Example response:
- ```json
- {
- "jsonapi": {
- "version": "1.0",
- "build": "build-id-1"
- },
- "data": {
- "id": 4
- }
- }
- ```
- ## Delete a company
- Deletes a company.
- ```
- DELETE /api/v1/companies/:id
- ```
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `id` | Integer | yes | ID of the company |
- Example request:
- ```
- DELETE /api/v1/companies/10
- ```
- Example response:
- ```
- 204 No Content
- ```
- # Custom field definitions
- ## List all custom field definitions
- Shows a list of all custom field definitions visible for current account.
- ```
- GET /api/v1/custom-field-definitions
- ```
- Example request:
- ```
- GET /api/v1/custom-field-definitions
- ```
- Example response:
- ```json
- {
- "jsonapi": {
- "version": "1.0",
- "build": "build-id-1"
- },
- "data": [
- {
- "id": 26,
- "name": "name",
- "fieldType": "String",
- "required": true,
- "fieldableType": "Company",
- "group": "Accounting",
- "additionalConfig": null
- }
- ]
- }
- ```
- ## Show a custom field definition
- Shows a single custom field definition with supplied id.
- ```
- GET /api/v1/custom-field-definitions/:id
- ```
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `id` | Integer | yes | ID of the custom field definition |
- Example request:
- ```
- GET /api/v1/custom-field-definitions/10
- ```
- Example response:
- ```json
- {
- "jsonapi": {
- "version": "1.0",
- "build": "build-id-1"
- },
- "data": {
- "id": 26,
- "name": "name",
- "fieldType": "Fields::List",
- "required": true,
- "fieldableType": "Company",
- "group": "Accounting",
- "additionalConfig": {
- "multiple": "true",
- "options": [
- ["Label1", "Value1"],
- ["Label2", "Value2"],
- ["Label3", "Value3"]
- ]
- }
- }
- }
- ```
- ## Create a new custom field definition
- Creates a new custom field definition.
- ```
- POST /api/v1/custom-field-definitions
- ```
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `name` | String | yes | Name of the field definition |
- | `fieldType` | String | yes | Type of the field's value |
- | `required` | boolean | yes | Information whether field is required for fieldable model |
- | `group` | Integer | no | ID of the group that field should belong to |
- | `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. |
- Example request:
- ```json
- {
- "data": {
- "name": "Select field",
- "fieldType": "Fields::List",
- "required": true,
- "group": 1,
- "additionalConfig": {
- "multiple": "true",
- "options": [
- ["Label1", "Value1"],
- ["Label2", "Value2"],
- ["Label3", "Value3"]
- ]
- }
- }
- }
- ```
- Example response:
- ```json
- {
- "jsonapi": {
- "version": "1.0",
- "build": "build-id-1"
- },
- "data": {
- "id": 4
- }
- }
- ```
- ## Update a custom field definition
- Updates custom field definition's data
- ```
- PUT /api/v1/custom-field-definitions/:id
- ```
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `id` | Integer | yes | ID of the custom field definition |
- | `name` | String | no | Name of the field definition |
- | `fieldType` | String | no | Type of the field's value |
- | `required` | boolean | no | Information whether field is required for model |
- | `group` | Integer | no | ID of the group that field should belong to |
- | `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. |
- Example request:
- ```json
- {
- "data": {
- "name": "name",
- "fieldType": "String",
- "required": true,
- "group": 1
- }
- }
- ```
- Example response:
- ```json
- {
- "jsonapi": {
- "version": "1.0",
- "build": "build-id-1"
- },
- "data": {
- "id": 4
- }
- }
- ```
- ## Delete a custom field definition
- Deletes a custom field definition.
- ```
- DELETE /api/v1/custom-field-definitions/:id
- ```
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `id` | Integer | yes | ID of the custom field definition |
- Example request:
- ```
- DELETE /api/v1/custom-field-definitions/10
- ```
- Example response:
- ```
- 204 No Content
- ```
- ## Change custom field definitions order
- Change an order of custom field definitions within group to be displayed in forms and show views.
- ```
- POST /api/v1/custom-field-definitions/change-order
- ```
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `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 |
- Example request:
- ```json
- {
- "data": {
- "order": {
- "1": [4,3,5,2,1],
- "3": [4,3,5,2,1],
- }
- }
- }
- ```
- Example response:
- ```
- 200 OK
- ```
- # Custom field groups
- ## List all custom field groups
- Shows a list of all custom field groups visible for current account.
- ```
- GET /api/v1/custom-field-groups
- ```
- Example request:
- ```
- GET /api/v1/custom-field-groups
- ```
- Example response:
- ```json
- {
- "jsonapi": {
- "version": "1.0",
- "build": "build-id-1"
- },
- "data": [
- {
- "id": 26,
- "name": "Accounting",
- "fieldableType": "Person",
- "orderedBy": 1,
- "customFieldDefinitions": [
- {
- "name": "phone",
- "fieldType": "String",
- "required": false
- }
- ],
- "accessRoles": [
- {
- "name": "role 1",
- "uniq_code": "abc123"
- }
- ]
- }
- ]
- }
- ```
- ## Show a custom field group
- Shows a single custom field group with supplied id.
- ```
- GET /api/v1/custom-field-groups/:id
- ```
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `id` | Integer | yes | ID of the custom field group |
- Example request:
- ```
- GET /api/v1/custom-field-groups/10
- ```
- Example response:
- ```json
- {
- "jsonapi": {
- "version": "1.0",
- "build": "build-id-1"
- },
- "data": {
- "id": 10,
- "name": "Accounting",
- "fieldableType": "Person",
- "orderedBy": 1,
- "customFieldDefinitions": [
- {
- "name": "phone",
- "fieldType": "String",
- "required": false
- }
- ],
- "accessRoles": [
- {
- "name": "role 1",
- "uniq_code": "acb123"
- }
- ]
- }
- }
- ```
- ## Create a new custom field group
- Creates a new custom field group.
- ```
- POST /api/v1/custom-field-group
- ```
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `name` | String | yes | Name of the field group |
- | `fieldableType` | String | yes | Name of the model to which group should be assigned |
- | `accessRoles` | Array | yes | Array of access roles' ids |
- Example request:
- ```json
- {
- "data": {
- "name": "Accounting",
- "fieldableType": "Person",
- "accessRoles": [1,2,3]
- }
- }
- ```
- Example response:
- ```json
- {
- "jsonapi": {
- "version": "1.0",
- "build": "build-id-1"
- },
- "data": {
- "id": 4
- }
- }
- ```
- ## Update a custom field group
- Updates custom field group's data
- ```
- PUT /api/v1/custom-field-groups/:id
- ```
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `id` | Integer | yes | ID of the custom field group |
- | `name` | String | no | Name of the field group |
- | `fieldableType` | String | yes | Name of the model to which group should be assigned |
- | `accessRoles` | Array | yes | Array of access roles' ids |
- Example request:
- ```json
- {
- "data": {
- "name": "Accounting",
- "fieldableType": "Person",
- "accessRoles": [1,2,3]
- }
- }
- ```
- Example response:
- ```json
- {
- "jsonapi": {
- "version": "1.0",
- "build": "build-id-1"
- },
- "data": {
- "id": 4
- }
- }
- ```
- ## Delete a custom field group
- Deletes a custom field group.
- ```
- DELETE /api/v1/custom-field-groups/:id
- ```
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `id` | Integer | yes | ID of the custom field group |
- Example request:
- ```
- DELETE /api/v1/custom-field-groups/10
- ```
- Example response:
- ```
- 204 No Content
- ```
- ## Change custom field groups order
- Change an order of custom field groups to be displayed in forms and show views.
- ```
- POST /api/v1/custom-field-groups/change-order
- ```
- | Attribute | Type | Required | Description |
- | ------------- | ------- | -------- | ---------------------------- |
- | `company` | Array | no | Array of groups ids in correct order. Groups related to Company model |
- | `person` | Array | no | Array of groups ids in correct order. Groups related to Person model |
- | `address` | Array | no | Array of groups ids in correct order. Groups related to Address model |
- | `contact` | Array | no | Array of groups ids in correct order. Groups related to Contact model |
- Example request:
- ```json
- {
- "data": {
- "company": [3,4,2,1],
- "person": [1,2,3,4],
- "address": [2,4,3,1],
- "contact": [1,4,2,3]
- }
- }
- ```
- Example response:
- ```
- 200 OK
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement