Skip to content

TimoPeraza/venmo-api

Repository files navigation

Venmo Api

Venmo Api is a mobile payment service which allows friends to transfer money to each other. It also has some social features like show your friends’ payment activities as feed. It's based on Rails 6 and Ruby 2.6.5.

Features

This template comes with:

  • Get the user balance
  • Send payment to a friend
  • Get feeds records

How to use

  1. Clone this repo
  2. Install PostgreSQL in case you don't have it
  3. Run bootstrap.sh with the name of your your project like ./bootstrap.sh my_awesome_project
  4. rspec and make sure all tests pass
  5. rails s
  6. You can now try your REST services!

Gems

Optional configuration

  • Set your frontend URL in config/initializers/rack_cors.rb
  • Set your mail sender in config/initializers/devise.rb
  • Config your timezone accordingly in application.rb.

Code quality

With rake code_analysis you can run the code analysis tool, you can omit rules with:

  • Rubocop Edit .rubocop.yml
  • Reek Edit config.reek
  • Rails Best Practices Edit config/rails_best_practices.yml
  • Brakeman Run brakeman -I to generate config/brakeman.ignore
  • Bullet You can add exceptions to a bullet initializer or in the controller

Configuring Code Climate

  1. After adding the project to CC, go to Repo Settings
  2. On the Test Coverage tab, copy the Test Reporter ID
  3. Set the current value of CC_TEST_REPORTER_ID in the circle-ci project env variables

Entity Relationship Diagram

Venmo Model

  • Friendship concept was handled as a bidirectional association (e.g user_a and user_b friendship will be represented as only one Friendship table entry, whether user_a or user_b value is on first_friend or second_friend attribute will be exactly the same for the system.)

  • Feed was associated to a Payment to keep a unique feed by transaction between users.

Api Docs

API HTTP verb URI Request Parameters Response
Payment POST /user/{id}/payment friend_id (integer), amount (float), description (string) Success: return 200 code with empty body.
Failure: return HTTP error code with error description.
Feed GET /user/{id}/feeds page (page_number for pagination, integer. If no page number in the params, return first page by default. Each page contains at most 10 feed items.) Success: return 200 code, body contains a list of feed items.
Failure: return HTTP error code with error description.
Balance check GET /user/{id}/balance No parameters Success: return 200 code, body contains balance.
Failure: return HTTP error code with error description.

Services

This project has 3 main services.

  • PaymentService handles the logic for creating a payment between two users. First it will validate that the receiver user is friend of the sender user and if the amount of money is a positive value, displaying the respective error message in case of failure. Then it will validate that the sender user's balance is equal or greater than the amount to transfer, if it's not it will proceed to call the service explained below. Finally if validations passed, a payment and a feed will be created.

  • Money Transfer Service mocks an external payment source connection which is called whenever a user tries to transfer an amount greater than his account's balance. The service will act as a successful request to an external party and will add the required value for the user to make the transfer.

  • FeedService will return all the payments that a given user should see on their feed. Such collection will be composed by his own payments plus his friends payments.

Code Owners

You can use CODEOWNERS file to define individuals or teams that are responsible for code in the repository.

Code owners are automatically requested for review when someone opens a pull request that modifies code that they own.

Credits

Rails Api Base is maintained by Rootstrap with the help of our contributors.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published