# API naming convention
**Currently, for all request we are dropping `get` from the name. This convention require further discussion.**
For e.g.,
##### Convention 1
```graphql=
query {
pie(id: String!) {
createdAt: String
investedAmount: Float
investments: [Investment]
name: String
pieId: String
status: String
}
}
```
##### Convention 2
```graphql=
query {
getPie(id: String!) {
createdAt: String
investedAmount: Float
investments: [Investment]
name: String
pieId: String
status: String
}
}
```
We are using **Convention [1](#Convention-1)**. We can go with either one.
## For getting list or all data
#### Convention 1
```graphql=
query {
pies {
quotes: [Quote!]
}
}
```
#### Convention 2
```graphql=
query {
allPies {
quotes: [Quote!]
}
}
```
#### Convention 3
```graphql=
query {
listPies {
quotes: [Quote!]
}
}
```
We are using **Convention [1](#Convention-11)** for this case right now.
***Needs confirmation so that both teams can be on common page.***
## Current API Schema
> The `userId` will be grabbed from the `Authorization` header if it is set.
```graphql=
{
"Authorization": "Bearer <token received>"
}
```
### Login with Phone Number
It is two step process.
```graphql=
mutation loginWithPhoneNumber(
prefix: String @optional
phoneNumber: String!
) {
token: String
}
```
> `token` is essential to confirm the login
#### Verify Phone Number login
```graphql=
mutation verifyPhoneNumber(
token: String! # received while loginWithPhoneNumber mutation
code: String! # otp code
) {
token: String # jwt token
refreshToken: String # refresh token (save it securely)
expiresAt: String # when will token expire
type: String # which auth type to use. E.g., bearer
}
```
> `token` is essential to validate the login, we need to confirm that device which requested the login is the same one.
### Login with Username
**Note: `loginWithUsername` makes more sense. Since, username is default for login in our app.**
```graphql=
mutation loginWithUsername(
username: String!
password: String!
) {
token: String # jwt token
refreshToken: String # refresh token (save it securely)
expiresAt: String # when will token expire
type: String # which auth type to use. E.g., bearer
}
```
> `username` can be username or email
### Verify Email
```graphql=
mutation verifyEmail(code: String!) {
ok: String! # ok denotes the status of email updation
}
```
## Forgot Password
```graphql=
mutation forgotPassword(username: String!) {
token: String! # essential to validate and update password for requested user
}
```
> `username` can be username or email
**Note: Should we make it generic or use two mutations?**
In case of generic mutation
```graphql=
mutation updatePassword(
token: String @required if user is not logged in
code: String @required if user is not logged in
password: String!
) {
ok: Boolean
}
```
Using the above mutation to set password for `mutation forgotPassword`
```graphql=
mutation updatePassword(
$token: String!,
$code: String!,
$password: String!
){
updatePassword(
token: $token,
code: $code,
password: $password
) {
ok: Boolean
}
}
```
Using the above mutation to set password for logged in user.
```graphql=
mutation updatePassword(
$password: String!
){
updatePassword(
password: $password
) {
ok: Boolean
}
}
```
## Sign up
```graphql=
mutation signUpWithPhoneNumber(
prefix: String @optional
phoneNumber: String!
) {
expiresAt: String
refreshToken: String
token: String
type: String
}
```
```graphql=
mutation verifyPhoneNumber(code: String!) {
ok: Boolean
}
```
```graphql=
mutation resendPhoneNumberVerificationCode(
prefix: String @optional
phoneNumber: String!
channel: PhoneChannelEnum
) {
token: String
}
```
```graphql=
enum PhoneChannelEnum {
sms
call
}
```
## NOTE: Code below has not been updated to match the current schema
Some queries and mutation requires to be updated according the naming scheme.
Please refer [API Naming Convention](#API-naming-convention).
As for updating all the schema is tedious and error prone. It also defeats the purpose of using GraphQL.
Please check [Flahmingo's Playground]( https://flahmingo.ferb.win/playground)
## What does this mean? updateProfile or something?
**Note: Requires clarification**
```graphql=
mutation chooseUser($idUser: User!, $dataAccount: DataAccount!) {
chooseUser(user: $idUser, dataAccount: $dataAccount) {
username
firstName
lastName
}
}
```
## Setup Account and Security
**Note: Requires clarification**
```
mutation chooseUser($idUser: User!, $dataAccount: DataAccount!) {
setupAccount(user: $idUser, dataAccount: $dataAccount) {
email
}
```
## Onboarding Questions
**Note: Require list of questions so we can make it more simpler.**
```
mutation howDoYouWantToUseFlahmingo($idUser: User!, $answer: Answer!){
howDoYouWantToUseFlahmingo(user: $idUser, answer: $answer){
answer
}
}
```
```
howDoYouWantToUseFlahmingo{
question
type
options
}
```
##
## Pies
```
mutation CreatePieforUser($idUser: User!, $stocks: StocksSelected!) {
createPie(user: $idUser, stocks: $stocks) {
stockSymbol
percentage
}
}
```
```
pieProjection{
profitValue
graphValue{
value
}
}
```
> PD: this graph show the stocks weighted average
```
pieDetail{
id
name
totalInvested
valueVariation
stocks{
stockSymbol
stockName
color
stockImage{
publicURL
name
}
percentage
shares
amountInvested
currentPrice
variationPrice
graphValues{
value
}
}
}
```
## Explore and Select Stocks
```
allStocks{
stockSymbol
stockName
stockImage{
publicURL
name
}
currentPrice
variationPrice
category
}
```
## Stock Detail
```
stockDetail(stockSymbol: “{eq: "APPL"}”) {
stockSymbol
stockName
about
stockImage
currentPrice
variationPrice
category
stats{
openPrice
priceToEarningsRatio
marketCap
oneYearHighPrice
oneYearLowPrice
volumenTrading
dividendYield
highestDay
lowestDay
}
}
```
```
stockGraph(stockSymbol: “{eq: “APPL”}”, rangeType: ”{eq: “day”}” ){
stockSymbol
rangeType
highPrice
lowPrice
graphValues{
value
date
}
}
```
```
stockNews{
id
sourceName
publishedDate
title
url
image{
publicURL
name
}
}
```
```
eventsStock{
stockSymbol
nameEvent
description
typeEvent
}
```
## Trading
```
>
mutation buyStock($idUser: User!, $pie: Pie!, $stock: Stock!) {
buyStock(user: $idUser, pie: $pie stock: $stock) {
stockSymbol
shares
priceOrder
typeOrder
}
}
```
```
balanceAccount{
cashBalance{
available
currency
}
account{
type
stocks{
stockSymbol
shares
}
}
}
```
```
quotationBuyStock{
stockSymbol
marketPrice
pricePerShare
EstimatedCost
datetime
}
```
```
mutation sellStock($idUser: User!, $pie: Pie!, $stock: Stock!) {
sellStock(user: $idUser, pie: $pie stock: $stock) {
stockSymbol
shares
priceOrder
typeOrder
}
}
```
```
quotationSellStock{
stockSymbol
pricePerShare
marketPrice
estimatedValue
datetime
}
```
## Dashboard
```
allPies{
id
name
status
totalInvested
variationValue
color
createdAt
stocks{
stockSymbol
}
graphPerformance{
value
}
}
```
```
allEvents{
stockSymbol
nameEvent
description
typeEvent
}
```
```
history{
orderNumber
price
stockSymbol
shares
currentStatus
logStatus{
status
modifiedAt
}
submittedAt
}
```
## Flamingo Central
- [ ] Pending because this feature is not defined completely
## Ask Questions
```
allQuestions{
stockSymbol
stockEventName
createdAt
status
questions{
question
answer
shares
votes
}
}
```
```
mutation askQuestion($idUser: User!, $stock: Stock!, $question: Question!) {
askQuestion(user: $idUser, stock: $stock, question: $question) {
stockSymbol
question
}
}
```
```
availableQuestions{
stockSymbol
available
}
```
## Settings
- [ ] Pending because this feature is not defined completely
## KYC Basic Data
```
mutation basicData($idUser: User!, $basicData: BasicData!) {
basicData(user: $idUser, basicData: $basicData) {
birhtdate
citizenship
gender
residentialAddress
mailingAddress
}
}
```
```
questionBasicData{
question
type
options
}
```
## KYC Employement Data
```
mutation employementData($idUser: User!, $employementData: EmployementData!) {
employementData(user: $idUser, employementData: $employementData) {
ocupation
companyName
companyType
jobTitle
socialInsuranceNumber
}
}
```
```
questionEmployementData{
question
type
options
}
```
## KYC Financial Data
```
mutation financialData($idUser: User!, $financialData: FinancialData!) {
financialData(user: $idUser, financialData: $financialData) {
goals
investingExperience
annualIncome
cashLiquidInvestments
questionsAboutYouAndFamilyMembers
}
}
```
```
questionsFinancialData{
question
type
options
}
```
## KYC Review and send data
```
mutation howDidYouHearAboutUs($idUser: User!, $answer: Answer!){
howDidYouHearAboutUs(user: $idUser, answer: $answer){
answer
}
}
```
```
howDidYouHearAboutUs{
question
type
options
}
```
## Funding account & Paild
```
hypotheticalEarnings{
earnings
totalInvestment
totalReturn
graphValues{
total
investment
return
year
}
}
```
```
mutation BankAccountLinked($idUser: User!, $accounts: Accounts!){
token
bank
type
endingNumbers
balance
transactions{
amount
description
date
}
}
```
>>> Maybe the token is enough and the backend can retrieve the rest of data
```
allBankAccountsLinked{
bank
type
endingNumbers
balance
transactions{
amount
description
date
}
}
```
```
allBanks{
code
name
image{
publicURL
name
}
}
```
## Notification
```
allNotifications{
title
description
datetime
deeplink
image{
publicURL
name
}
}
```
## Voting
```
mutation vote($idUser: User!, $vote: Vote!) {
vote(user: $idUser, vote: $vote) {
proposal
vote
}
}
```
```
allVotingProposals{
id
stockSymbol
event
description
type
options{
value
}
}
```
## Referall
- [ ] Pending to define designs
<!--stackedit_data:
eyJoaXN0b3J5IjpbLTM0MjMwMjk2MywxMTQ2MzI1ODM1XX0=
-->