diff --git a/connect.go b/connect.go index eeeea5e..87f63a5 100644 --- a/connect.go +++ b/connect.go @@ -94,6 +94,7 @@ const ( URIUserSessionInvalidate string = "/session/token" URIUserSessionRenew string = "/session/refresh_token" URIUserProfile string = "/user/profile" + URIFullUserProfile string = "/user/profile/full" URIUserMargins string = "/user/margins" URIUserMarginsSegment string = "/user/margins/%s" // "/user/margins/{segment}" diff --git a/connect_test.go b/connect_test.go index af89948..55251b3 100644 --- a/connect_test.go +++ b/connect_test.go @@ -114,6 +114,7 @@ var MockResponders = [][]string{ // GET endpoints {http.MethodGet, URIUserProfile, "profile.json"}, + {http.MethodGet, URIFullUserProfile, "full_profile.json"}, {http.MethodGet, URIUserMargins, "margins.json"}, {http.MethodGet, URIUserMarginsSegment, "margins_equity.json"}, {http.MethodGet, URIGetOrders, "orders.json"}, diff --git a/mock_responses b/mock_responses index 0dd520a..8afe0ed 160000 --- a/mock_responses +++ b/mock_responses @@ -1 +1 @@ -Subproject commit 0dd520a4b2d871d599920b0fbb7ba2c158499b93 +Subproject commit 8afe0ed9d1f0efbdf9e568859e32c33a26694aef diff --git a/user.go b/user.go index d58a7b0..a696b0f 100644 --- a/user.go +++ b/user.go @@ -39,6 +39,13 @@ type UserMeta struct { DematConsent string `json:"demat_consent"` } +// FullUserMeta contains full meta data of the user. +type FullUserMeta struct { + DematConsent string `json:"poa"` + Silo string `json:"silo"` + AccountBlocks []string `json:"account_blocks"` +} + // UserProfile represents a user's personal and financial profile. type UserProfile struct { UserID string `json:"user_id"` @@ -54,6 +61,28 @@ type UserProfile struct { Exchanges []string `json:"exchanges"` } +type FullUserProfile struct { + UserID string `json:"user_id"` + UserName string `json:"user_name"` + AvatarURL string `json:"avatar_url"` + UserType string `json:"user_type"` + Email string `json:"email"` + Phone string `json:"phone"` + Broker string `json:"broker"` + TwoFAType string `json:"twofa_type"` + Banks []Bank `json:"bank_accounts"` + DPIDs []string `json:"dp_ids"` + Products []string `json:"products"` + OrderTypes []string `json:"order_types"` + Exchanges []string `json:"exchanges"` + PAN string `json:"pan"` + UserShortName string `json:"user_shortname"` + Tags []string `json:"tags"` + PasswordTimestamp models.Time `json:"password_timestamp"` + TwoFATimestamp models.Time `json:"twofa_timestamp"` + Meta FullUserMeta `json:"meta"` +} + // Margins represents the user margins for a segment. type Margins struct { Category string `json:"-"` @@ -178,6 +207,13 @@ func (c *Client) GetUserProfile() (UserProfile, error) { return userProfile, err } +// GetFullUserProfile gets full user profile. +func (c *Client) GetFullUserProfile() (FullUserProfile, error) { + var fUserProfile FullUserProfile + err := c.doEnvelope(http.MethodGet, URIFullUserProfile, nil, nil, &fUserProfile) + return fUserProfile, err +} + // GetUserMargins gets all user margins. func (c *Client) GetUserMargins() (AllMargins, error) { var allUserMargins AllMargins diff --git a/user_test.go b/user_test.go index 8dd010c..20a24c7 100644 --- a/user_test.go +++ b/user_test.go @@ -12,6 +12,14 @@ func (ts *TestSuite) TestGetUserProfile(t *testing.T) { } } +func (ts *TestSuite) TestGetFullUserProfile(t *testing.T) { + t.Parallel() + fullProfile, err := ts.KiteConnect.GetFullUserProfile() + if err != nil || fullProfile.Email == "" || fullProfile.UserID == "" { + t.Errorf("Error while reading full user profile. Error: %v", err) + } +} + func (ts *TestSuite) TestGetUserMargins(t *testing.T) { t.Parallel() margins, err := ts.KiteConnect.GetUserMargins()