• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

madeindjs/market_place_api_6: Code example of API on Rails 6 book https://github ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

madeindjs/market_place_api_6

开源软件地址:

https://github.com/madeindjs/market_place_api_6

开源编程语言:

Ruby 99.5%

开源软件介绍:

Market Place API

This repository contains application example build into the API on Rails 6 book.

This final application will scratch the surface of being a market place where users will be able to place orders, upload products and more. There are plenty of options out there to set up an online store, such as Shopify, Spree or Magento.

The purpose of this application is not only to teach you how to build an API with Rails but rather to teach you how to build an evolutive and maintainable API with Rails. That is, improve your current knowledge with Rails. On this journey, you will learn to:

  • Building JSON responses
  • Test your end-points with unit and functional tests
  • Set up authentication with JSON Web Tokens (JWT)
  • Optimize and cache the API

Setup

git clone https://github.com/madeindjs/market_place_api_6
cd market_place_api_6
bundle install
rake db:create
rake db:migrate

Usage

Create user

curl -X POST -d 'user[email][email protected]' -d 'user[password]=toto1234' localhost:3000/api/v1/users

Obtain token

curl -X POST -d 'user[email][email protected]' -d 'user[password]=toto1234' localhost:3000/api/v1/tokens

Manage product

export TKN="eyJhbG...WqaXAcnE" # from /api/v1/tokens
# create
curl -X POST -H "Authorization: $TKN" -d "product[title]=Bag" -d "product[price]=10" localhost:3000/api/v1/products
# update: publish and add stock
curl -X PATCH -H "Authorization: $TKN" -d "product[published]=true" -d "product[quantity]=2" localhost:3000/api/v1/products/19
# list
curl -H "Authorization: $TKN" localhost:3000/api/v1/products
# delete
curl -X DELETE -H "Authorization: $TKN" localhost:3000/api/v1/products/19

Manage order

export TKN="eyJhbG...WqaXAcnE" # from /api/v1/tokens
# create
curl -X POST -H "Authorization: $TKN" -d "order[product_ids_and_quantities][][product_id]=20" -d "order[product_ids_and_quantities][][quantity]=1" localhost:3000/api/v1/orders
# list
curl -H "Authorization: $TKN" localhost:3000/api/v1/orders
# show
curl -H "Authorization: $TKN" localhost:3000/api/v1/orders/7

Requirments

  • Ruby 2.5+
  • Sqlite



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap