From d36ecde7819232487ec5da39e8e98b126330f7a5 Mon Sep 17 00:00:00 2001 From: Ritesh Shrivastav Date: Tue, 21 Nov 2023 12:39:04 +0530 Subject: [PATCH 1/5] feat: Add Full User Profile --- connect.go | 1 + connect_test.go | 1 + user.go | 29 +++++++++++++++++++++++++++++ user_test.go | 8 ++++++++ 4 files changed, 39 insertions(+) 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/user.go b/user.go index d58a7b0..3c15190 100644 --- a/user.go +++ b/user.go @@ -54,6 +54,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 string `json:"password_timestamp"` + TwoFATimestamp string `json:"twofa_timestamp"` + Meta UserMeta `json:"meta"` +} + // Margins represents the user margins for a segment. type Margins struct { Category string `json:"-"` @@ -178,6 +200,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() From 4ffcb439c90b5d28deaa548acb541c7841ca0ae3 Mon Sep 17 00:00:00 2001 From: Ritesh Shrivastav Date: Tue, 21 Nov 2023 12:50:42 +0530 Subject: [PATCH 2/5] feat: Update mock response for Full User Profile --- mock_responses | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mock_responses b/mock_responses index 0dd520a..b7aa6e9 160000 --- a/mock_responses +++ b/mock_responses @@ -1 +1 @@ -Subproject commit 0dd520a4b2d871d599920b0fbb7ba2c158499b93 +Subproject commit b7aa6e91c6f4d8388ccaf93070c7553baddd2b2a From b7590002402ed071f8bd0a20911a0f2bed1c99cb Mon Sep 17 00:00:00 2001 From: Ritesh Shrivastav Date: Tue, 21 Nov 2023 12:58:36 +0530 Subject: [PATCH 3/5] Add FullUserMeta for full user profile --- mock_responses | 2 +- user.go | 45 ++++++++++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/mock_responses b/mock_responses index b7aa6e9..7c3509d 160000 --- a/mock_responses +++ b/mock_responses @@ -1 +1 @@ -Subproject commit b7aa6e91c6f4d8388ccaf93070c7553baddd2b2a +Subproject commit 7c3509d53b7b1d8ed73b5dfd8ecc8b1abf40ef1b diff --git a/user.go b/user.go index 3c15190..4cbed2f 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"` @@ -55,25 +62,25 @@ type UserProfile struct { } 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 string `json:"password_timestamp"` - TwoFATimestamp string `json:"twofa_timestamp"` - Meta UserMeta `json:"meta"` + 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 string `json:"password_timestamp"` + TwoFATimestamp string `json:"twofa_timestamp"` + Meta FullUserMeta `json:"meta"` } // Margins represents the user margins for a segment. From 1612a1adb9a3ff23494b002713d91b5a650d29e4 Mon Sep 17 00:00:00 2001 From: Ritesh Shrivastav Date: Tue, 21 Nov 2023 15:39:47 +0530 Subject: [PATCH 4/5] Make timestamps time object Use PAN instead of Pan in struct --- user.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/user.go b/user.go index 4cbed2f..a696b0f 100644 --- a/user.go +++ b/user.go @@ -75,11 +75,11 @@ type FullUserProfile struct { Products []string `json:"products"` OrderTypes []string `json:"order_types"` Exchanges []string `json:"exchanges"` - Pan string `json:"pan"` + PAN string `json:"pan"` UserShortName string `json:"user_shortname"` Tags []string `json:"tags"` - PasswordTimestamp string `json:"password_timestamp"` - TwoFATimestamp string `json:"twofa_timestamp"` + PasswordTimestamp models.Time `json:"password_timestamp"` + TwoFATimestamp models.Time `json:"twofa_timestamp"` Meta FullUserMeta `json:"meta"` } From 970add147d89211b51f768d45726a4bda53d3e39 Mon Sep 17 00:00:00 2001 From: Ritesh Shrivastav Date: Tue, 21 Nov 2023 15:46:52 +0530 Subject: [PATCH 5/5] Fix tests hash --- mock_responses | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mock_responses b/mock_responses index 7c3509d..8afe0ed 160000 --- a/mock_responses +++ b/mock_responses @@ -1 +1 @@ -Subproject commit 7c3509d53b7b1d8ed73b5dfd8ecc8b1abf40ef1b +Subproject commit 8afe0ed9d1f0efbdf9e568859e32c33a26694aef