Giter VIP home page Giter VIP logo

mycorp_greeting's Introduction

Mycorp Greeting

An example module to create custom services in Drupal 7

Goals

  1. Creates greetings content type along with the required fields
  2. Creates Rest server resource named "Greeting" with CRUD operation and a publish action
  3. Allows users to create, update, delete, fetch, publish and unpublish Greeting content using REST API

Installation

Install greetings_feature and mycorp_greeting like any other Drupal module and create greeting content to play around with the API.

REST API Documentation

Retrieve greeting

Return a specific greeting of given id.

  • URL

    api/v1/greetings/{id}

  • Method:
    GET

  • URL Params

    Required: id=[integer] - ID of the greeting to return

  • Success Response:

    Returns the greeting content field values.

    • Code: 200
      Content: { "uid": "1", "title": "Test greeting 1", "log": "", "status": "1" }
  • Error Response:

    • Code: 404 NOT FOUND
      Content: { error : "Greeting not found" }

Create greeting

Create a new greeting. Need to login using api/v1/user/login and obtain the token to create a new greeting

  • URL

    api/v1/greetings

  • Method:
    POST

  • Data Params

    Required: title=[text] - Title of the greeting to be created

    optional: field_greeting_image=[url] - Image URL for the greeting to be created

  • Success Response:

    Returns the created greeting nid.

    • Code: 200
      Content: 1
  • Error Response:

    • Code: 401 UNAUTHORIZED
      Content: { error : "Log in" }

Delete greeting

Delete a specific greeting of given id.

  • URL

    api/v1/greetings/{id}

  • Method:
    DELETE

  • URL Params

    Required: id=[integer] - ID of the greeting to delete

  • Success Response:

    Returns TRUE

  • Error Response:

    • Code: 401 UNAUTHORIZED
      Content: { error : "Log in" }

Update greeting

Update a greeting of given id. Need to login using api/v1/user/login and obtain the token to update a greeting

  • URL

    api/v1/greetings/{id}

  • Method:
    PUT

  • URL Params

    Required: id=[integer] - ID of the greeting to update

  • Data Params

    title=[text] - Title of the greeting to be created field_greeting_image=[url] - Image URL for the greeting to be created

  • Success Response:

    Returns the updated greeting values.

    • Code: 200
      Content: { "uid": "1", "title": "Test greeting 1", "log": "", "status": "1" }
  • Error Response:

    • Code: 401 UNAUTHORIZED
      Content: { error : "Log in" }

Publish / unpublish greeting

Publish / unpublish a specific greeting of given id.

  • URL

    api/v1/greetings/{id}/publish

  • Method:
    POST

  • URL Params

    Required: id=[integer] - ID of the greeting to publish / unpublish

  • Success Response:

    Returns TRUE

  • Error Response:

    • Code: 401 UNAUTHORIZED
      Content: { error : "Log in" }

mycorp_greeting's People

Contributors

pravinajaaz avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.