# SomanyMittr API Doc
Base URL: ```https://somany-mittr-backend.herokuapp.com```
## Log In
### Get OTP
**[POST]:** ```/users/get_otp```
**Body:**
```json
{
"user_mobile_number":"9811874801"
}
```
**Response:**
```json
{
"otp": "1572"
}
```
### Log In
**[POST]:** ```/tokens.json```
**Body:**
```json
{
"user_mobile_number":"9811874801",
"otp":"1572"
}
```
**Response:**
```json
{
"token": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOjIsImV4cCI6MTYyNzYyNDcxOX0.reSvcCyiIqHAPSVs1Dg9AbilP7NuN4Q3FW7tpPl97io"
}
```
## Sign Up
### Check Submit Status before Photo Upload
**[POST]:** ```/users/check_sign_up.json```
**Body:**
```json
{
"user_mobile_number":"9818346665"
}
```
**Response:**
* 200 -> Good to go for sign up
* 409 -> Signup under process
* 422 -> User already registered
### Get Signup OTP
**[POST]:** ```/signup_otps/get_otp.json```
**Body:**
```json
{
"signup_mobile_number":"9811874801"
}
```
**Response:
```json
{
"status":"<status from the provider>",
"otp":2789
}
```
### Verify Signup OTP
**[POST]:** ```/signup_otps/verify_otp.json```
**Body:**
```json
{
"otp":2789
}
```
**Response:**
**200 OK**
```json
{
"status":"OTP valid"
}
```
**404 Not Found**
```json
{
"status":"OTP invalid"
}
```
### Actual Signup
**[POST]:** ```/users/sign_up.json```
**Body:**
```json
{
"user_mobile_number":"9818346665",
"user_identification_number":"<ID num>",
"id_photo_urls":["<id_photo_aws_url_1>","<id_photo_aws_url_2>"]
}
```
**Response:**
* 200 -> Good to go for sign up
* 409 -> Signup under process
* 422 -> User already registered
<u>Note:</u> Check note in **submit information** below on photo-url logic
## Profile
### Get User Info
**[GET]:** ```/users.json```
**Headers:** ```Authorization: Bearer <token>```
**Body:** *EMPTY*
**Response:**
```json
{
"id": 2,
"user_first_name": "Shrivatsa",
"user_last_name": "Somany",
"user_mobile_number": "9811874801",
"user_dob": "1989-06-27T00:00:00.000Z",
"user_photo_url": "<image_url>",
"user_type": 1,
"verified_balance": 541,
"unverified_balance": 25,
"redeemed_balance": 84,
"zone_id": 6
}
```
## Home Page
### Get Home Info
**[GET]:** ```/home.json```
**Headers:** ```Authorization: Bearer <token>```
**Body:** *EMPTY*
**Response:**
```json
{
"user_id": 2,
"user_first_name": "Shrivatsa",
"user_last_name": "Somany",
"user_mobile_number": "9811874801",
"user_photo_url": "<image_url>",
"user_type": 1,
"verified_balance": 541,
"unverified_balance": 25,
"redeemed_balance": 84,
"zone_id": 6,
"vendor_access_token":"<ACCESS_TOKEN>"
"banners": ["<image_url_1>", "<image_url_2>", "<image_url_3>"]
}
```
## Scan Page
### Product Lookup
**[GET]:** ```/products/find_products.json?product_name=<product_name>```
**Note:** ***This is a temporary measure till the QR Code system is live and in the market***
Use this to look up the product code to then send to the API below for the points information etc.
**Headers:** ```Authorization: Bearer <token>```
**Body:** *EMPTY*
**Response:**
```json
[
{
"id":2,
"product_id":77197124,
"product_name":"Thistle Single Lever Faucet",
"product_points": 500,
"multiplier": 2.0
}
]
```
### Product Information (QR Code Scan)
**[GET]:** ```/products/get_info.json?product_id=<scanned_code>```
**Headers:** ```Authorization: Bearer <token>```
**Body:** *EMPTY*
**Response:**
```json
{
"product_id":77197124,
"product_name":"Thistle Single Lever Faucet",
"product_points": 500,
"multiplier": 2.0
}
```
<u>Note:</u> The product points and multiplier will be calculated and sent from the server. The multiplier is only to show if they got a certain offer on it or not. In short, don't multiply the points with the multiplier on the client side.
### Dealer Information
**[GET]:** ```/dealers/find_dealers.json```
<u>Note:</u> Please send the information only when the character count in the input field is **≥ 3**
**Headers:** ```Authorization: Bearer <token>```
**Body:**
```json
{
"query":"J.B.",
"lat":28.613939,
"lon":77.209023
}
```
**Response:**
```json
[
{
"id":1,
"dealer_name": "J.B. Gupta & Sons Pvt. Ltd.",
"dealer_address": "1512, WAZIR NAGAR, Bhishma Pitamah Marg, opp. DEFENCE COLONY, Kotla Mubarakpur, New Delhi",
"dealer_pin_code": "110003",
"dealer_state": "Delhi"
}
]
```
<u>Note:</u> Some more information is also visible (like State, Address etc.)
### Submit Information to Credit Points
**[POST]:** ```/transactions/submit_credit_request.json```
**Headers:** ```Authorization: Bearer <token>```
**Body:**
```json
{
"product_id":"AABBCC123456",
"dealer_id": 1, //null if dealer is not in the system
"dealer_name": "J.B. Gupta & Sons Pvt. Ltd.",
"transaction_points":1000,
"bill_copy_urls":["<bill_1_photo_url>", "<bill_2_photo_url>"],
"lat":28.613939,
"lon":77.209023
}
```
<u>Note:</u> This is assuming bills are uploaded to the AWS bucket from the client. This is prefered because it avoids double uploading (once from the client to server, and then server to AWS), and also keeps the server resources free of any heavy tasks. We should build in image-compression where it's still legible, but small enough to store.
## Store Page
### Get Reward Item List
**[GET]:** ```/reward_items.json```
**Headers:** ```Authorization: Bearer <token>```
**Response:**
```json
[
{
"id": 1,
"mittr_prices": "15000,30000",
"vendor_product_id": 57598,
"product_name": "Airtel Recharge",
"vendor_denomenations": "500,1000",
"new_reward_item":false,
"vendor_product_photo":"photo_url/somewhere/photo.jpg"
},
{
"id": 2,
"mittr_price": "30000,60000",
"vendor_product_id": 57599,
"product_name": "Kalyan Gold Coin Gift Card",
"vendor_denomenations": "1000,2000",
"new_reward_item":true,
"vendor_product_photo":"photo_url/somewhere/photo.jpg"
}
]
```
### Post Debit Transaction
**[POST]:** ```/transactions/submit_debit_request.json```
**Headers:** ```Authorization: Bearer <token>```
**Body:**
```json
{
"reward_item_id":2,
"transaction_points":30000,
"vendor_product_id":57599
"vendor_order_id":8891,
"vendor_denomination":1000
}
```
## History
### Reward History
**[GET]:** /reward_items/reward_history.json
**Headers:** ```Authorization: Bearer <token>```
**Response:**
```json
[
{
"id": 4,
"transaction_points": 15000,
"vendor_order_id": 6171,
"vendor_product_id": 57598,
"vendor_denomination": 500,
"reward_item_name": "Airtel Voucher - ₹500",
"vendor_product_photo": "<photo_url>"
},
{
"id": 6,
"transaction_points": 30000,
"vendor_order_id": 6172,
"vendor_product_id": 57598,
"vendor_denomination": 1000,
"reward_item_name": "Airtel Voucher - ₹500",
"vendor_product_photo": "<photo_url>"
}
]
```
### Transaction History
#### Transaction Types:
1. Credit
2. Debit
#### Transaction Statuses:
1. Unverified
2. Verified
3. Rejected
**[GET]:** /transactions.json
**Headers:** ```Authorization: Bearer <token>```
**Response:**
```json
[
{
"id": 1,
"user_id": 4,
"product_id": 4,
"product": {
"id": 4,
"product_name": "Thistle Single Lever Faucet"
},
"scheme_id": null,
"transaction_points": 1000,
"transaction_type": 1,
"reward_item_id": null,
"dealer_id": 1,
"rejection_reason": null,
"vendor_order_id": null,
"vendor_denomination": null
},
{
"id": 2,
"user_id": 4,
"product_id": 4,
"product": {
"id": 4,
"product_name": "Thistle Single Lever Faucet"
},
"scheme_id": null,
"transaction_points": 1000,
"transaction_type": 1,
"reward_item_id": null,
"dealer_id": 1,
"rejection_reason": null,
"vendor_order_id": null,
"vendor_denomination": null
},
{
"id": 3,
"user_id": 4,
"product_id": 4,
"product": {
"id": 4,
"product_name": "Thistle Single Lever Faucet"
},
"scheme_id": null,
"transaction_points": 1000,
"transaction_type": 1,
"reward_item_id": null,
"dealer_id": 1,
"rejection_reason": null,
"vendor_order_id": null,
"vendor_denomination": null
},
{
"id": 4,
"user_id": 4,
"product_id": 4,
"product": {
"id": 4,
"product_name": "Thistle Single Lever Faucet"
},
"scheme_id": null,
"transaction_points": 1000,
"transaction_type": 1,
"reward_item_id": null,
"dealer_id": 1,
"rejection_reason": null,
"vendor_order_id": null,
"vendor_denomination": null
},
{
"id": 5,
"user_id": 4,
"product_id": 4,
"product": {
"id": 4,
"product_name": "Thistle Single Lever Faucet"
},
"scheme_id": null,
"transaction_points": 1000,
"transaction_type": 1,
"reward_item_id": null,
"dealer_id": 1,
"rejection_reason": null,
"vendor_order_id": null,
"vendor_denomination": null
},
{
"id": 8,
"user_id": 4,
"product_id": null,
"scheme_id": null,
"transaction_points": 30000,
"transaction_type": 2,
"reward_item_id": 4,
"reward_item": {
"id": 4,
"mittr_prices": "15000,30000,70000",
"vendor_product_id": 6903,
"product_name": "Myntra",
"created_at": "2021-08-10T10:51:34.651Z",
"updated_at": "2021-08-30T11:11:42.988Z",
"vendor_denomenations": "500,1000,2000",
"new_reward_item": false,
"vendor_product_photo": null
},
"dealer_id": null,
"rejection_reason": null,
"vendor_order_id": 8891,
"vendor_denomination": 1000
},
{
"id": 9,
"user_id": 4,
"product_id": null,
"scheme_id": null,
"transaction_points": 30000,
"transaction_type": 2,
"reward_item_id": 4,
"reward_item": {
"id": 4,
"mittr_prices": "15000,30000,70000",
"vendor_product_id": 6903,
"product_name": "Myntra",
"created_at": "2021-08-10T10:51:34.651Z",
"updated_at": "2021-08-30T11:11:42.988Z",
"vendor_denomenations": "500,1000,2000",
"new_reward_item": false,
"vendor_product_photo": null
},
"dealer_id": null,
"rejection_reason": null,
"vendor_order_id": 8891,
"vendor_denomination": 2000
},
{
"id": 12,
"user_id": 4,
"product_id": 5,
"product": {
"id": 5,
"product_name": "Prada Single Lever Basin Mixer"
},
"scheme_id": null,
"transaction_points": 58,
"transaction_type": 1,
"reward_item_id": null,
"dealer_id": 1,
"rejection_reason": null,
"vendor_order_id": null,
"vendor_denomination": null
},
{
"id": 16,
"user_id": 4,
"product_id": 7,
"product": {
"id": 7,
"product_name": "Vida Shower Column"
},
"scheme_id": null,
"transaction_points": 1733,
"transaction_type": 1,
"reward_item_id": null,
"dealer_id": 2,
"rejection_reason": null,
"vendor_order_id": null,
"vendor_denomination": null
},
{
"id": 17,
"user_id": 4,
"product_id": 6,
"product": {
"id": 6,
"product_name": "Odette Angular Stop Valve"
},
"scheme_id": null,
"transaction_points": 130,
"transaction_type": 1,
"reward_item_id": null,
"dealer_id": 3,
"rejection_reason": null,
"vendor_order_id": null,
"vendor_denomination": null
},
{
"id": 20,
"user_id": 4,
"product_id": 14,
"product": {
"id": 14,
"product_name": "Evita Glass Shelf Corner"
},
"scheme_id": null,
"transaction_points": 106,
"transaction_type": 1,
"reward_item_id": null,
"dealer_id": 1,
"rejection_reason": null,
"vendor_order_id": null,
"vendor_denomination": null
},
{
"id": 21,
"user_id": 4,
"product_id": null,
"scheme_id": null,
"transaction_points": 1300,
"transaction_type": 2,
"reward_item_id": 3,
"reward_item": {
"id": 3,
"mittr_prices": "350,1300",
"vendor_product_id": 228,
"product_name": "Cafe Coffee Day",
"created_at": "2021-08-10T10:51:34.646Z",
"updated_at": "2021-08-30T11:11:42.983Z",
"vendor_denomenations": "50,100",
"new_reward_item": false,
"vendor_product_photo": null
},
"dealer_id": null,
"rejection_reason": null,
"vendor_order_id": 6181214,
"vendor_denomination": 100
},
{
"id": 22,
"user_id": 4,
"product_id": null,
"scheme_id": null,
"transaction_points": 1300,
"transaction_type": 2,
"reward_item_id": 3,
"reward_item": {
"id": 3,
"mittr_prices": "350,1300",
"vendor_product_id": 228,
"product_name": "Cafe Coffee Day",
"created_at": "2021-08-10T10:51:34.646Z",
"updated_at": "2021-08-30T11:11:42.983Z",
"vendor_denomenations": "50,100",
"new_reward_item": false,
"vendor_product_photo": null
},
"dealer_id": null,
"rejection_reason": null,
"vendor_order_id": 6181214,
"vendor_denomination": null
},
{
"id": 24,
"user_id": 4,
"product_id": null,
"scheme_id": null,
"transaction_points": 1300,
"transaction_type": 2,
"reward_item_id": 3,
"reward_item": {
"id": 3,
"mittr_prices": "350,1300",
"vendor_product_id": 228,
"product_name": "Cafe Coffee Day",
"created_at": "2021-08-10T10:51:34.646Z",
"updated_at": "2021-08-30T11:11:42.983Z",
"vendor_denomenations": "50,100",
"new_reward_item": false,
"vendor_product_photo": null
},
"dealer_id": null,
"rejection_reason": null,
"vendor_order_id": 6181214,
"vendor_denomination": 100
},
{
"id": 25,
"user_id": 4,
"product_id": null,
"scheme_id": null,
"transaction_points": 350,
"transaction_type": 2,
"reward_item_id": 3,
"reward_item": {
"id": 3,
"mittr_prices": "350,1300",
"vendor_product_id": 228,
"product_name": "Cafe Coffee Day",
"created_at": "2021-08-10T10:51:34.646Z",
"updated_at": "2021-08-30T11:11:42.983Z",
"vendor_denomenations": "50,100",
"new_reward_item": false,
"vendor_product_photo": null
},
"dealer_id": null,
"rejection_reason": null,
"vendor_order_id": 6181244,
"vendor_denomination": 50
},
{
"id": 26,
"user_id": 4,
"product_id": null,
"scheme_id": null,
"transaction_points": 350,
"transaction_type": 2,
"reward_item_id": 3,
"reward_item": {
"id": 3,
"mittr_prices": "350,1300",
"vendor_product_id": 228,
"product_name": "Cafe Coffee Day",
"created_at": "2021-08-10T10:51:34.646Z",
"updated_at": "2021-08-30T11:11:42.983Z",
"vendor_denomenations": "50,100",
"new_reward_item": false,
"vendor_product_photo": null
},
"dealer_id": null,
"rejection_reason": null,
"vendor_order_id": 6181246,
"vendor_denomination": 50
},
{
"id": 27,
"user_id": 4,
"product_id": null,
"scheme_id": null,
"transaction_points": 350,
"transaction_type": 2,
"reward_item_id": 3,
"reward_item": {
"id": 3,
"mittr_prices": "350,1300",
"vendor_product_id": 228,
"product_name": "Cafe Coffee Day",
"created_at": "2021-08-10T10:51:34.646Z",
"updated_at": "2021-08-30T11:11:42.983Z",
"vendor_denomenations": "50,100",
"new_reward_item": false,
"vendor_product_photo": null
},
"dealer_id": null,
"rejection_reason": null,
"vendor_order_id": 6181282,
"vendor_denomination": 50
},
{
"id": 28,
"user_id": 4,
"product_id": null,
"scheme_id": null,
"transaction_points": 350,
"transaction_type": 2,
"reward_item_id": 3,
"reward_item": {
"id": 3,
"mittr_prices": "350,1300",
"vendor_product_id": 228,
"product_name": "Cafe Coffee Day",
"created_at": "2021-08-10T10:51:34.646Z",
"updated_at": "2021-08-30T11:11:42.983Z",
"vendor_denomenations": "50,100",
"new_reward_item": false,
"vendor_product_photo": null
},
"dealer_id": null,
"rejection_reason": null,
"vendor_order_id": 6181283,
"vendor_denomination": 50
},
{
"id": 29,
"user_id": 4,
"product_id": null,
"scheme_id": null,
"transaction_points": 350,
"transaction_type": 2,
"reward_item_id": 3,
"reward_item": {
"id": 3,
"mittr_prices": "350,1300",
"vendor_product_id": 228,
"product_name": "Cafe Coffee Day",
"created_at": "2021-08-10T10:51:34.646Z",
"updated_at": "2021-08-30T11:11:42.983Z",
"vendor_denomenations": "50,100",
"new_reward_item": false,
"vendor_product_photo": null
},
"dealer_id": null,
"rejection_reason": null,
"vendor_order_id": 6181373,
"vendor_denomination": 50
}
]
```