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 branch 'master' of https://github.com/bitcoin-sv/spv-wallet int…
…o BUX-246/Linters
- Loading branch information
Showing
25 changed files
with
1,248 additions
and
343 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
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" | ||
) | ||
|
||
// accept will accept contact request | ||
// Accept contact godoc | ||
// @Summary Accept contact | ||
// @Description Accept contact. For contact with status "awaiting" change status to "unconfirmed" | ||
// @Tags Contact | ||
// @Produce json | ||
// @Param paymail path string true "Paymail address of the contact the user wants to accept" | ||
// @Success 200 | ||
// @Failure 404 "Contact not found" | ||
// @Failure 422 "Contact status not awaiting" | ||
// @Failure 500 "Internal server error" | ||
// @Router /v1/contact/accepted/{paymail} [PATCH] | ||
// @Security x-auth-xpub | ||
func (a *Action) accept(c *gin.Context) { | ||
reqXPubID := c.GetString(auth.ParamXPubHashKey) | ||
paymail := c.Param("paymail") | ||
|
||
err := a.Services.SpvWalletEngine.AcceptContact(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
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
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" | ||
) | ||
|
||
// reject will reject contact request | ||
// Reject contact godoc | ||
// @Summary Reject contact | ||
// @Description Reject contact. For contact with status "awaiting" delete contact | ||
// @Tags Contact | ||
// @Produce json | ||
// @Param paymail path string true "Paymail address of the contact the user wants to reject" | ||
// @Success 200 | ||
// @Failure 404 "Contact not found" | ||
// @Failure 422 "Contact status not awaiting" | ||
// @Failure 500 "Internal server error" | ||
// @Router /v1/contact/rejected/{paymail} [PATCH] | ||
// @Security x-auth-xpub | ||
func (a *Action) reject(c *gin.Context) { | ||
reqXPubID := c.GetString(auth.ParamXPubHashKey) | ||
paymail := c.Param("paymail") | ||
|
||
err := a.Services.SpvWalletEngine.RejectContact(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 was deleted.
Oops, something went wrong.
Oops, something went wrong.