Giter Site home page Giter Site logo

chatapi's Introduction

applications-chats-api

API for creating chats in RoR & Golang

Install

sudo docker-compose down && sudo docker-compose build && sudo docker-compose up

Make sure that port 3000 & '8080' is availble to allow the API to run on it.

Rails API availble end points

- Applications end points

GET   /applications/
POST  /applications?name={name}
GET   /applications/{application_token}
PUT   /applications/{application_token}?name={name}

- Chats end points
GET   /applications/{application_token}/chats
GET   /applications/{application_token}/chats/{chat_number}

- Messages end points
GET   /applications/{application_token}/chats/{chat_number}/messages
GET   /applications/{application_token}/chats/{chat_number}/messages/{message_number}
GET   /applications/{application_token}/chats/{chat_number}/messages/search?keyword={keyword}
PUT   /applications/{application_token}/chats/{chat_number}/messages/{message_number}?body={message_body}

Go API availble end points

- Applications end points

POST  /applications/{application_token}/chats/
POST  /applications/{application_token}/chats/{chat_number}/messages?body={message_body}

Examples

Let's start by create new application:

-Request
GET 'http://localhost:3000/applications?name=newApp'

# Response
{
  "name": "newApp",
  "created_at": "2022-01-01T01:10:00",
  "updated_at": "2022-01-01T01:10:00",
  "chat_count": 0
  "application_token": "bs2oCw18zFGVUJmCAmTFhuBN",
}

Then create new Chat:

POST 'http://localhost:8080/applications/bs2oCw18zFGVUJmCAmTFhuBN/chats'

# Response
{
 "number": 1,
 "application_token": "bs2oCw18zFGVUJmCAmTFhuBN"
}

Then create new message:

'{"body": "New Messages"}'  POST 'http://localhost:8080/applications/bs2oCw18zFGVUJmCAmTFhuBN/chats/1/messages'

# Response
{
 "number": 1,
 "chat_number":1,
 "application_token": "bs2oCw18zFGVUJmCAmTFhuBN"
}

Search for chat messages

 GET 'http://localhost:3000/applications/bs2oCw18zFGVUJmCAmTFhuBN/chats/1/messages/search?keyword=New'

# output
[
  {
    "number": 1,
    "body": "New Messages",
    "created_at": "2022-01-01T01:10:00.351Z",
    "updated_at": "2022-01-01T01:10:00.351Z"
  }
]

chatapi's People

Contributors

samra10 avatar

Watchers

 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.