mirror of
https://github.com/wahyd4/loginsrv.git
synced 2026-08-09 04:46:29 +10:00
#51 | Refactored name for getPrimaryEmailAddress auxiliary method
This commit is contained in:
+4
-3
@@ -10,6 +10,7 @@ import (
|
||||
)
|
||||
|
||||
var bitbucketAPI = "https://api.bitbucket.org/2.0"
|
||||
|
||||
// Using the avatar url to be able to fetch 128px image. By default BitbucketAPI return 32px image.
|
||||
var bitbucketAvatarURL = "https://bitbucket.org/account/%v/avatar/128/"
|
||||
|
||||
@@ -45,8 +46,8 @@ type email struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
}
|
||||
|
||||
// GetPrimaryEmailAddress retrieve the primary email address of the user
|
||||
func (e *emails) GetPrimaryEmailAddress() string {
|
||||
// getPrimaryEmailAddress retrieve the primary email address of the user
|
||||
func (e *emails) getPrimaryEmailAddress() string {
|
||||
for _, val := range e.Values {
|
||||
if val.IsPrimary {
|
||||
return val.Email
|
||||
@@ -124,7 +125,7 @@ var providerBitbucket = Provider{
|
||||
Sub: gu.Username,
|
||||
Picture: fmt.Sprintf(bitbucketAvatarURL, gu.Username),
|
||||
Name: gu.DisplayName,
|
||||
Email: userEmails.GetPrimaryEmailAddress(),
|
||||
Email: userEmails.getPrimaryEmailAddress(),
|
||||
Origin: "bitbucket",
|
||||
}, string(b), nil
|
||||
},
|
||||
|
||||
@@ -123,7 +123,7 @@ func (suite *BitbucketTestSuite) Test_Bitbucket_getPrimaryEmailAddress() {
|
||||
userEmails := emails{}
|
||||
err := json.Unmarshal([]byte(bitbucketTestUserEmailResponse), &userEmails)
|
||||
suite.NoError(err)
|
||||
suite.Equal("tutorials@bitbucket.com", userEmails.GetPrimaryEmailAddress())
|
||||
suite.Equal("tutorials@bitbucket.com", userEmails.getPrimaryEmailAddress())
|
||||
}
|
||||
|
||||
// Test_Bitbucket_Suite Runs the entire suite for Bitbucket
|
||||
|
||||
Reference in New Issue
Block a user