Skip to content

Instantly share code, notes, and snippets.

@okmit
Last active November 23, 2019 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okmit/205f22f66d97f5d1ad351ecfc7b3c51b to your computer and use it in GitHub Desktop.
Save okmit/205f22f66d97f5d1ad351ecfc7b3c51b to your computer and use it in GitHub Desktop.

HR Employee Create

  • URL

    /v1/employees

  • Method:

    POST

  • HEADERS

    Authorization=bearer ACCESS_TOKEN

  • Data Params

    employee[email]=[text]
    employee[full_name]=[text]
    employee[password]=[]
    employee[password_confirmation]=[text]
    employee[phone_number]=[text]
    employee[files_attributes][0][file]=[file]
    employee[permission_ids][]=[integer]
    employee[hr_position_id]=[integer]

  • Success Response:

    • Code: 201 CREATED
      Content: {"data":
      {"employee":{
      "id":28,
      "email":"demo@gnail.com",
      "phone_number":"4524566",
      "full_name":"demo name",
      "permissions":[

      {"id":1,"resource_name":"employee","permit":"read_all"},
      {"id":2,"resource_name":"employee","permit":"manage"}]
      }}}
  • Error Response:

    • Code: 401 UNAUTHORIZED
      Content: { error": "Invalid access token" }

    OR

    • Code: 401 UNAUTHORIZED
      Content { error: 'You don't have permission' }

    OR

    • Code: 422 UNPROCESSABLE ENTITY
      Content: {"errors":{
      "email":["can't be blank","is invalid"],
      "password":["can't be blank"],
      "full_name":["can't be blank"],
      "phone_number":["can't be blank"]}}
  • Sample Call:

  • Notes:

HR Employee Delete

  • URL

    /v1/employees/:id

  • Method:

    DELETE

  • HEADERS

    Authorization=bearer ACCESS_TOKEN

  • URL Params

    Required:

    id=[integer]

  • Data Params

  • Success Response:

    • Code: 200 OK
      Content:
  • Error Response:

    • Code: 401 UNAUTHORIZED
      Content: { error": "Invalid access token" }

    OR

    • Code: 401 UNAUTHORIZED
      Content { error: 'You don't have permission' }

    OR

    • Code 404 NOT FOUND
      Content: { error: "Not Found" }

    OR

    • Code: 404 UNPROCESSABLE ENTITY
      Content:
  • Sample Call:

  • Notes:

HR Employee Update

  • URL

    /v1/employees/:id

  • Method:

    PUT | PATCH

  • HEADERS

    Authorization=bearer ACCESS_TOKEN

  • URL Params

    Required:

    id=[integer]

  • Data Params

    employee[email]=[text]
    employee[full_name]=[text]
    employee[password]=[]
    employee[password_confirmation]=[text]
    employee[phone_number]=[text]
    employee[files_attributes][0][file]=[file]
    employee[permission_ids][]=[integer]
    employee[hr_position_id]=[integer]

  • Success Response:

    • Code: 200 OK
      Content: {"data":
      {"employee":{
      "id":28,
      "email":"demo@gnail.com",
      "phone_number":"4524566",
      "full_name":"demo name",
      "permissions":[

      {"id":1,"resource_name":"employee","permit":"read_all"},
      {"id":2,"resource_name":"employee","permit":"manage"}]
      }}}
  • Error Response:

    • Code: 401 UNAUTHORIZED
      Content: { error": "Invalid access token" }

    OR

    • Code: 401 UNAUTHORIZED
      Content { error: 'You don't have permission' }

    OR

    • Code 404 NOT FOUND
      Content: { error: "Not Found" }

    OR

    • Code: 404 UNPROCESSABLE ENTITY
      Content: {"errors":{"phone_number":["can't be blank"]}}
  • Sample Call:

  • Notes:

HR Employees

  • URL

    /v1/employees

  • Method:

    GET

  • HEADERS

    Authorization=bearer ACCESS_TOKEN

  • URL Params

    Required:

    none

    Optional:

    per_page=[integer]
    page=[integer]
    'q[email_eq]'=[text]
    'q[email_cont]'=[text]
    'q[full_name_eq]'=[text]
    'q[full_name_cont]'=[text]
    'q[phone_number_eq]'=[text]
    'q[phone_number_cont]'=[text]
    ...

  • Data Params

    none

  • Success Response:

    • Code: 200 OK
      Content: {"data":{
      "employees":[
      {"id":3,"full_name":"Demo1","email":"demi1@dvl.com","phone_number":"2345567"},

      {"id":20,"full_name":"Demo2","email":"demo2@gnail.com","phone_number":"2345567"}
      ],
      "pagination":{"page":1,"per_page":2,"total":10,"pages":5}}}
  • Error Response:

    • Code: 401 UNAUTHORIZED
      Content: { error": "Invalid access token" }

    OR

    • Code: 401 UNAUTHORIZED
      Content { error: 'You don't have permission' }
  • Sample Call:

  • Notes:

in search query

*_eq - equal
*_cont Contains value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment