Skip to content

Commit

Permalink
feat(BUX-184): add admin/paymail/get endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mwilkosinski committed Oct 10, 2023
1 parent 29e977c commit f3f3698
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 2 deletions.
30 changes: 30 additions & 0 deletions actions/admin/paymail_addresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,36 @@ import (
apirouter "github.com/mrz1836/go-api-router"
)

// paymailGetAddress will return a paymail address
// Get Paymail godoc
// @Summary Get paymail
// @Description Get paymail
// @Tags Admin
// @Param address query string true "address"
// @Produce json
// @Success 200
// @Router /v1/admin/paymail/get [get]
// @Security bux-auth-xpub
func (a *Action) paymailGetAddress(w http.ResponseWriter, req *http.Request, _ httprouter.Params) {
params := apirouter.GetParams(req)
address := params.GetString("address")

if address == "" {
apirouter.ReturnResponse(w, req, http.StatusExpectationFailed, "address is required")
return
}

opts := a.Services.Bux.DefaultModelOptions()

paymailAddress, err := a.Services.Bux.GetPaymailAddress(req.Context(), address, opts...)
if err != nil {
apirouter.ReturnResponse(w, req, http.StatusExpectationFailed, err.Error())
return
}

apirouter.ReturnResponse(w, req, http.StatusOK, paymailAddress)
}

// paymailAddressesSearch will fetch a list of paymail addresses filtered by metadata
// Paymail addresses search by metadata godoc
// @Summary Paymail addresses search
Expand Down
1 change: 1 addition & 0 deletions actions/admin/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func RegisterRoutes(router *apirouter.Router, appConfig *config.AppConfig, servi
router.HTTPRouter.POST("/"+config.CurrentMajorVersion+"/admin/block-headers/count", action.Request(router, require.Wrap(action.blockHeadersCount)))
router.HTTPRouter.POST("/"+config.CurrentMajorVersion+"/admin/destinations/search", action.Request(router, require.Wrap(action.destinationsSearch)))
router.HTTPRouter.POST("/"+config.CurrentMajorVersion+"/admin/destinations/count", action.Request(router, require.Wrap(action.destinationsCount)))
router.HTTPRouter.POST("/"+config.CurrentMajorVersion+"/admin/paymail/get", action.Request(router, require.Wrap(action.paymailGetAddress)))
router.HTTPRouter.POST("/"+config.CurrentMajorVersion+"/admin/paymails/search", action.Request(router, require.Wrap(action.paymailAddressesSearch)))
router.HTTPRouter.POST("/"+config.CurrentMajorVersion+"/admin/paymails/count", action.Request(router, require.Wrap(action.paymailAddressesCount)))
router.HTTPRouter.POST("/"+config.CurrentMajorVersion+"/admin/paymail/create", action.Request(router, require.Wrap(action.paymailCreateAddress)))
Expand Down
63 changes: 62 additions & 1 deletion docs/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 59 additions & 1 deletion docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,37 @@
}
}
},
"/v1/admin/paymail/get": {
"get": {
"security": [
{
"bux-auth-xpub": []
}
],
"description": "Get paymail",
"produces": [
"application/json"
],
"tags": [
"Admin"
],
"summary": "Get paymail",
"parameters": [
{
"type": "string",
"description": "address",
"name": "address",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/v1/admin/paymails/count": {
"post": {
"security": [
Expand Down Expand Up @@ -1712,6 +1743,33 @@
}
}
},
"/v1/utxo/unreserve": {
"patch": {
"security": [
{
"bux-auth-xpub": []
}
],
"description": "Unreserve UTXOs",
"tags": [
"UTXO"
],
"summary": "Unreserve UTXOs",
"parameters": [
{
"type": "string",
"description": "draft tx id",
"name": "reference_id",
"in": "query"
}
],
"responses": {
"201": {
"description": "Created"
}
}
}
},
"/v1/xpub": {
"get": {
"security": [
Expand Down Expand Up @@ -1813,4 +1871,4 @@
"in": "header"
}
}
}
}
35 changes: 35 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,25 @@ paths:
summary: Delete paymail
tags:
- Admin
/v1/admin/paymail/get:
get:
description: Get paymail
parameters:
- description: address
in: query
name: address
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
security:
- bux-auth-xpub: []
summary: Get paymail
tags:
- Admin
/v1/admin/paymails/count:
post:
description: Paymail addresses count
Expand Down Expand Up @@ -1069,6 +1088,22 @@ paths:
summary: Search UTXO
tags:
- UTXO
/v1/utxo/unreserve:
patch:
description: Unreserve UTXOs
parameters:
- description: draft tx id
in: query
name: reference_id
type: string
responses:
"201":
description: Created
security:
- bux-auth-xpub: []
summary: Unreserve UTXOs
tags:
- UTXO
/v1/xpub:
get:
description: Get xPub
Expand Down

0 comments on commit f3f3698

Please sign in to comment.