generated from mrz1836/go-template
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #523 from bitcoin-sv/feat-648-restful-contacts
feat(BUX-648): restful contact api
- v1.0.0-beta.43
- v1.0.0-beta.42
- v1.0.0-beta.41
- v1.0.0-beta.40
- v1.0.0-beta.39
- v1.0.0-beta.38
- v1.0.0-beta.37
- v1.0.0-beta.36
- v1.0.0-beta.35
- v1.0.0-beta.34
- v1.0.0-beta.33
- v1.0.0-beta.32
- v1.0.0-beta.31
- v1.0.0-beta.30
- v1.0.0-beta.29
- v1.0.0-beta.28
- v1.0.0-beta.27
- v1.0.0-beta.26
- v1.0.0-beta.25
- v1.0.0-beta.24
- v1.0.0-beta.23
- v1.0.0-beta.22
- v1.0.0-beta.21
- v1.0.0-beta.20
- v1.0.0-beta.19
- v1.0.0-beta.18
- v1.0.0-beta.17
- v1.0.0-beta.16
- v1.0.0-beta.15
- v1.0.0-beta.14
- v1.0.0-beta.13
- v1.0.0-beta.12
- v1.0.0-beta.11
- v1.0.0-beta.10
- v1.0.0-beta.9
- v1.0.0-beta.8
- v1.0.0-beta.7
- v1.0.0-beta.6
- v1.0.0-beta.5
- v1.0.0-beta.4
- v1.0.0-beta.3
- v1.0.0-beta.2
- v1.0.0-beta.1
- v0.28.0
- v0.27.3
- v0.27.2
- v0.27.1
- v0.27.0
- v0.26.0
- models/v1.0.0-beta.43
- models/v1.0.0-beta.42
- models/v1.0.0-beta.41
- models/v1.0.0-beta.40
- models/v1.0.0-beta.39
- models/v1.0.0-beta.38
- models/v1.0.0-beta.37
- models/v1.0.0-beta.36
- models/v1.0.0-beta.35
- models/v1.0.0-beta.34
- models/v1.0.0-beta.33
- models/v1.0.0-beta.32
- models/v1.0.0-beta.31
- models/v1.0.0-beta.30
- models/v1.0.0-beta.29
- models/v1.0.0-beta.28
- models/v1.0.0-beta.27
- models/v1.0.0-beta.26
- models/v1.0.0-beta.25
- models/v1.0.0-beta.24
- models/v1.0.0-beta.23
- models/v1.0.0-beta.22
- models/v1.0.0-beta.21
- models/v1.0.0-beta.20
- models/v1.0.0-beta.19
- models/v1.0.0-beta.18
- models/v1.0.0-beta.17
- models/v1.0.0-beta.16
- models/v1.0.0-beta.15
- models/v1.0.0-beta.14
- models/v1.0.0-beta.13
- models/v1.0.0-beta.12
- models/v1.0.0-beta.11
- models/v1.0.0-beta.10
- models/v1.0.0-beta.9
- models/v1.0.0-beta.8
- models/v1.0.0-beta.7
- models/v1.0.0-beta.6
- models/v1.0.0-beta.5
- models/v1.0.0-beta.4
- models/v1.0.0-beta.3
- models/v1.0.0-beta.2
- models/v1.0.0-beta.1
- models/v0.28.0
- models/v0.27.3
- models/v0.27.2
- models/v0.27.1
- models/v0.27.0
- models/v0.26.0
- engine/v1.0.0-beta.14
- engine/v1.0.0-beta.13
- engine/v1.0.0-beta.12
- engine/v1.0.0-beta.11
- engine/v1.0.0-beta.10
- engine/v1.0.0-beta.9
- engine/v1.0.0-beta.8
- engine/v1.0.0-beta.7
- engine/v1.0.0-beta.6
- engine/v1.0.0-beta.5
- engine/v1.0.0-beta.4
- engine/v1.0.0-beta.3
- engine/v1.0.0-beta.2
- engine/v1.0.0-beta.1
- engine/v0.27.3
- engine/v0.27.2
- engine/v0.27.1
- engine/v0.27.0
- engine/v0.26.0
Showing
23 changed files
with
742 additions
and
571 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package contacts | ||
|
||
import ( | ||
"errors" | ||
"net/http" | ||
|
||
"github.com/bitcoin-sv/spv-wallet/engine" | ||
"github.com/bitcoin-sv/spv-wallet/server/auth" | ||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
// confirm will confirm contact request | ||
// Confirm contact godoc | ||
// @Summary Confirm contact | ||
// @Description Confirm contact. For contact with status "unconfirmed" change status to "confirmed" | ||
// @Tags Contact | ||
// @Produce json | ||
// @Param paymail path string true "Paymail address of the contact the user wants to confirm" | ||
// @Success 200 | ||
// @Failure 404 "Contact not found" | ||
// @Failure 422 "Contact status not unconfirmed" | ||
// @Failure 500 "Internal server error" | ||
// @Router /v1/contact/confirmed/{paymail} [PATCH] | ||
// @Security x-auth-xpub | ||
func (a *Action) confirm(c *gin.Context) { | ||
reqXPubID := c.GetString(auth.ParamXPubHashKey) | ||
paymail := c.Param("paymail") | ||
|
||
err := a.Services.SpvWalletEngine.ConfirmContact(c, reqXPubID, paymail) | ||
|
||
if err != nil { | ||
switch { | ||
case errors.Is(err, engine.ErrContactNotFound): | ||
c.JSON(http.StatusNotFound, err.Error()) | ||
case errors.Is(err, engine.ErrContactIncorrectStatus): | ||
c.JSON(http.StatusUnprocessableEntity, err.Error()) | ||
default: | ||
c.JSON(http.StatusInternalServerError, err.Error()) | ||
} | ||
return | ||
} | ||
c.Status(http.StatusOK) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.