Code Monkey home page Code Monkey logo

rentacar's Introduction

Rent a Car (Whatsapp API)

Installation

The project is build on Symfony 6 and the PHP version of the language being used is PHP 8.1. Install symfony on your local machine

  • Run the following command in order to set up the project

# Install dependencies
composer update
# or
composer install

# Migrate 
php bin/console doctrine:migrations:migrate

# Run Server
symfony server:start -d

# Add and set value in your .env.local for the following environment variables
ROOT_DIR=
  • Using the whatsapp api

The matricula against the phone number to which the message has to be sent should be present in the XML file under the directory xml/resentrega.xml

  • Testing the whatsapp api

    • One way to test is sending three messages to the following whatsapp number +34810101298 and go to the symfony profiler and get their request payloads and use them in POSTMAN or any other api tool. Following are the messages that should be sent

      • Matricula (This is the unique id against the mobile number in xml/resentrega.xml)
      • Upload an Image or Video

    • Firstly, we need to send the whatsapp text with the matricula assigned to us so that our number can be stored in the database. This can be used as test payload against the url using POSTMAN or any other api tool.

      https://rentacar.wardcampbell.com/rentacar

      # REQUEST METHOD => POST
      # REQUEST PAYLOAD =>
      {
          "contacts": [
              {
                  "profile": {
                      "name": "NAME"
                  },
                  "wa_id": "NUMBER"
              }
          ],
          "messages": [
              {
                  "from": "NUMBER",
                  "id": "RANDOMLY_GENERATED_ID",
                  "text": {
                      "body": "MATRICULA"
                  },
                  "timestamp": "1663331304",
                  "type": "text"
              }
          ]
      }
      # RESPONSE
      {
        "message": "OK"
      }

      You should be receiving a whatsapp message asking to upload images of the car

    • Now upload the media. This can be used as test payload against the url using postman or any other api tool.
      https://rentacar.wardcampbell.com/rentacar

      # FOR IMAGE
      # REQUEST METHOD => POST
      # REQUEST PAYLOAD =>
      {
          "contacts": [
              {
                  "profile": {
                      "name": "NAME"
                  },
                  "wa_id": "NUMBER"
              }
          ],
          "messages": [
              {
                  "from": "NUMBER",
                  "id": "RANDOMLY_GENERATED_ID",
                  "image": {
                      "id": "MEDIA_ID",
                      "mime_type": "image\/jpeg",
                      "sha256": "RANDOMLY_GENERATED"
                  },
                  "timestamp": "1663328754",
                  "type": "image"
              }
          ]
      }
      # FOR VIDEO
      # REQUEST METHOD => POST
      # REQUEST PAYLOAD =>
      {
          "contacts": [
              {
                  "profile": {
                      "name": "NAME"
                  },
                  "wa_id": "NUMBER"
              }
          ],
          "messages": [
              {
                  "from": "NUMBER",
                  "id": "NUMBER",
                  "timestamp": "1663334840",
                  "type": "video",
                  "video": {
                      "id": "MEDIA_ID",
                      "mime_type": "video\/mp4",
                      "sha256": "RANDOMLY_GENERATED"
                  }
              }
          ]
      }
      # RESPONSE
      {
        "message": "OK"
      }
    • The language of the messages sent to the user is processed in the WhatsApp Message Service Processor based on the REFERENCIARES11 entity in the resentrega.xml file. The default language is ESPANOL -> es.

      • FRANCES -> FR
      • INGLES -> EN
      • ALEMAN -> DE
      • ESPANOL -> ES
    • The messages that are being received can be seen under the /messages URL, you need to be logged in to see the table. In the table, the statuses of the messages that are received sent are also visible.

GOOD LUCK :)

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.