Skip to content

big-sem/evm-api-md

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 

Repository files navigation

API

Authentication

POST /api/v1/user/otp-request

body:

{
  phone: "+976 8666 1488" //international format
}

response: 200

POST /api/v1/user/otp-check

body:

{
  phone: string
  code: string //0000 - for dev
}

response:

{
  token: string
  profile: {
    name: string
    email: string
    phone: string
    balance: number
  },
  device?: {
    _id: string
    deviceNumber: string
    location: [number, number] //array of lenght 2
    waitingPrice: number
    price: number
  }
  nats: {
    servers: string
    topic: string
    user: string
    pass: string
  }
}

POST /api/v1/user/me

response:

{
  token: string
  profile: {
    name: string
    email: string
    phone: string
    balance: number
  },
  device?: {
    _id: string
    deviceNumber: string
    location: [number, number] //array of lenght 2
    waitingPrice: number
    price: number
  }
  nats: {
    servers: string
    topic: string
    user: string
    pass: string
  }
}

Note: NATS is used as event bus, consider using this package

POST /api/v1/customer/update-notification-token

body:

{
  FCMToken: string
}

response: 200

POST /api/v1/customer/update-info

body

{
    name: string
    email: string
}

response: 200

Chargers

GET /api/v1/devices/by-location

query:

{
  'bottom-left-longitude': number
  'bottom-left-latitude': number
  'upper-right-longitude': number
  'upper-right-latitude': number
}

response:

[
  {
    _id: string
    deviceNumber: string
    price: number
    waitingPrice: number
    location: [number, number] //Longitude, Latitude
    state: 'Idle' | 'Busy' | 'Repair' | 'Error'
  },
  ...
]

example: /api/v1/devices/by-location?bottom-left-longitude=69.9&bottom-left-latitude=69.9&upper-right-longitude=127&upper-right-latitude=80


Post /api/v1/devices/:id/start

response: 200

This message will be emitted from the server every 2-5 seconds

//{subject}.CHARGING
{
  energy: number
  waitingTime: number
  amount: number
}

If server

Post /api/v1/devices/:id/finish

response: Purchase id

{ 
  id: "12d76c8bfca2a22c07a6fca1"
}

Purchases

Get /api/v1/payment-options

response:

[
  {
    option: string
    icon: string
    title: string
    disabled: true
  }
]

Post /api/v1/purchases/:id/pay

params: id is purchase id obtained from the request above

body:

{ 
  option: string 
}

response:

//EVM
{
  option: 'EVM'
  invoiceId: string //purchase id
  newBalance: number
}
//QPAY
{
  option: 'QPAY'
  invoiceId: string
  url: string
}
//Other payment options are disabled for now

Note: use url_launcher (or any other similar package) to open url for payment. After successful payment, the following message will be emitted from the server:

//{subject}.PAYMENT
{
  status: 'success' | 'fail'
  amount: number
}

Post /api/v1/purchases/:id/status

Desc: for manually checking the payment status

body:

{
  invoiceId: string
}

response:

{
  status: 'pending' | 'success' | 'error' | 'canceled'
  amount: number
}

Post /api/v1/purchases/:id/feedback

body:

{
  feedback: {
    score: number, // 1-5
    description: string
  }
}

response: 200

example: /api/v1/purchases/12d76c8bfca2a22c07a6fca1/feedback

Get /api/v1/purchases

params:

{
  page: number // from 1
  'page-size': number //optional, 50 by default
}

response: check postman

Balance

Post /api/v1/customer/replenish

body:

{
  amount: number
  option: string
}

response:

//QPAY
{
  option: 'QPAY'
  invoiceId: string
  url: string
}
//Other payment options are disabled for now

Note: after successful replenishment, the following message will be emitted from the server:

//{subject}.REPLENISHMENT
{
  status: "success"
  amount: 10069
}

Post /api/v1/customer/replenishment/

Desc: for manually checking the replenishment status

body:

{
  invoiceId: string
}

response:

{
  status: 'pending' | 'success' | 'error' | 'canceled'
  amount: number
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published