Giter Site home page Giter Site logo

order_payments_service's Introduction

sinatra_customers_management_api

This project is an API for managing a customer database. It has been developed using Ruby Sinatra and PostgreSQL

Features

  • API Key Authentication.
  • Creating new customers through a JSON API.
  • Viewing customer details by ID.
  • Paginated listing of customers with the ability to specify the number of items per page.

Technologies

  • Ruby
  • Sinatra
  • PostgreSQL
  • Docker

Installation

Clone the repository to your local machine:

git clone https://github.com/vxd/order_payments_service.git
cd order_payments_service

Running the Application

Running the Application Locally (without Docker)

  1. Install all necessary gems:
bundle install
  1. Set up a .env file with the appropriate values derived from .env.example
  2. Create database:
bundle exec rake db:create
  1. Run the database migration:
bundle exec rake db:migrate
  1. Test the app:
bundle exec rspec
  1. Run the app:
bundle exec rackup -o 0.0.0.0 -p 4567

Running the Application using Docker

  1. Install Docker and Docker Compose. Ruby should be installed on your machine.
  2. Build and run the application using Docker Compose:
docker-compose up

The application will be accessible at http://localhost:4567.

Working with the API

Use an HTTP client such as curl or Postman to interact with the API.

Request Examples:

  1. Create new customers:
curl -X POST -H "Content-Type: application/json" -H "X-Api-Key: your_api_key" -d '[{"first_name": "John", last_name: "Doe", patronymic_name: "David", "email": "[email protected]"}, {"first_name": "Jane", last_name: "Doe", patronymic_name: "Steven", "email": "[email protected]"}]' http://localhost:4567/customers
  1. Get a list of all customers:
curl -X GET -H "X-Api-Key: your_api_key" http://localhost:4567/customers

you also can set page and per_page query parameters:

curl -X GET -H "X-Api-Key: your_api_key" http://localhost:4567/customers?page=1&per_page=5
  1. Get customer information by ID:
curl -X GET -H "X-Api-Key: your_api_key" http://localhost:4567/customers/1
  1. Create new order:
curl -X POST -H "Content-Type: application/json" -H "X-Api-Key: your_api_key" -d '[{"total": 1000, "user_id": 1 }, {"total": 2000, "user_id": 1 }]' http://localhost:4567/orders
  1. Get a list of all order:
curl -X GET -H "X-Api-Key: your_api_key" http://localhost:4567/orders

you also can set page and per_page query parameters:

curl -X GET -H "X-Api-Key: your_api_key" http://localhost:4567/orders?page=1&per_page=1
  1. Get order information by ID:
curl -X GET -H "X-Api-Key: your_api_key" http://localhost:4567/orders/1

order_payments_service's People

Contributors

vxd 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.