Skip to content

Commit

Permalink
Update swagger docs for Earnings
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewWestberg committed Jul 30, 2024
1 parent 99f8fb3 commit 287f8da
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,13 @@ class EarningsRepositoryImpl(
amount = (totalNewmAmount * (streamTokenAmount.setScale(6) / totalSupply.setScale(6))).toLong(),
memo = "Royalty for: ${song.title} - ${user.stageOrFullName}$exchangeRate",
createdAt = now,
startDate = now.plusHours(24),
startDate = if (cardanoRepository.isMainnet()) {
// wait 24 hours before starting the royalties
now.plusHours(24)
} else {
// on testnet, start immediately
now
},
)
}
addAll(earnings)
Expand Down Expand Up @@ -227,15 +233,19 @@ class EarningsRepositoryImpl(
transaction {
EarningEntity
.wrapRows(
EarningEntity.searchQuery(EarningsTable.songId eq songId).orderBy(EarningsTable.createdAt, SortOrder.DESC)
EarningEntity
.searchQuery(EarningsTable.songId eq songId)
.orderBy(EarningsTable.createdAt, SortOrder.DESC)
).map { it.toModel() }
}

override suspend fun getAllByStakeAddress(stakeAddress: String): List<Earning> =
transaction {
EarningEntity
.wrapRows(
EarningEntity.searchQuery(EarningsTable.stakeAddress eq stakeAddress).orderBy(EarningsTable.createdAt, SortOrder.DESC)
EarningEntity
.searchQuery(EarningsTable.stakeAddress eq stakeAddress)
.orderBy(EarningsTable.createdAt, SortOrder.DESC)
).map { it.toModel() }
}

Expand Down
24 changes: 17 additions & 7 deletions newm-server/src/main/resources/openapi/documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ paths:
post:
tags:
- "Earnings"
description: ""
description: "Create earnings for a song"
parameters:
- name: "songId"
in: "path"
Expand All @@ -691,14 +691,25 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/AddSongRoyaltyRequest"
examples:
Example#1:
value: |-
{
"songId": "f9d3fa34-378b-42c0-b070-0e834c2a36cc",
"usdAmount": 50000000
}
description: "USD amount (6 decimals - $50_USD) to be distributed to the song's contributors"
Example#2:
value: |-
{
"songId": "f9d3fa34-378b-42c0-b070-0e834c2a36cc",
"newmAmount": 123456000000
}
description: "NEWM amount (6 decimals - 123456 NEWM) to be distributed to the song's contributors"
required: true
responses:
"201":
description: "Created"
content:
'application/json':
schema:
type: "object"
/v1/idenfy/callback:
post:
tags:
Expand Down Expand Up @@ -2350,8 +2361,7 @@ components:
- "earningsIds"
- "createdAt"
BigInteger:
type: "object"
properties: { }
type: "integer"
AddSongRoyaltyRequest:
type: "object"
properties:
Expand Down

0 comments on commit 287f8da

Please sign in to comment.