Skip to content

Commit 1b44495

Browse files
authored
Add user invite authorisation options (#622)
* Removed redundant merchant role url builders. * Added user inite authorisation type. * Added isauthorised flag to the user invite model.
1 parent 89e3f8e commit 1b44495

File tree

6 files changed

+41
-13
lines changed

6 files changed

+41
-13
lines changed

src/NoFrixion.MoneyMoov/Enums/ApprovalTypesEnum.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,7 @@ public enum ApproveTypesEnum
3535

3636
Payrun = 8,
3737

38-
MerchantToken = 9
38+
MerchantToken = 9,
39+
40+
UserInvite = 10,
3941
}

src/NoFrixion.MoneyMoov/Enums/AuthorisationType.cs

100644100755
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ public enum AuthorisationType
2222
Rule = 2,
2323
Beneficiary = 3,
2424
Payrun = 4,
25-
MerchantToken = 5
25+
MerchantToken = 5,
26+
UserInvite = 6
2627
}

src/NoFrixion.MoneyMoov/Enums/UserInviteStatusEnum.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,10 @@ public enum UserInviteStatusEnum
3131
/// <summary>
3232
/// User has accepted the invite but the role is pending.
3333
/// </summary>
34-
Accepted = 2
34+
Accepted = 2,
35+
36+
/// <summary>
37+
/// The invite needs to be authorised before being activated.
38+
/// </summary>
39+
AuthorisationRequired = 3,
3540
}

src/NoFrixion.MoneyMoov/Models/Token/MerchantToken.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ public MerchantTokenPermissionsEnum Permissions
134134
public bool IsArchived { get; set; }
135135

136136
/// <summary>
137-
/// Gets a hash of the critical fields for the beneficiary. This hash is
138-
/// used to ensure a beneficiary's details are not modified between the time the
139-
/// authorisation is given and the time the beneficiary is enabled.
137+
/// Gets a hash of the critical fields for the merhcant token. This hash is
138+
/// used to ensure a merchant token's details are not modified between the time the
139+
/// authorisation is given and the time the merchant token is enabled.
140140
/// </summary>
141-
/// <returns>A hash of the beneficiary's critical fields.</returns>
141+
/// <returns>A hash of the merchant token's critical fields.</returns>
142142
public string GetApprovalHash()
143143
{
144144
var input =

src/NoFrixion.MoneyMoov/Models/UserInvite/UserInvite.cs

100644100755
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,20 @@ public class UserInvite
5050
/// </summary>
5151
public Guid? InitialRoleID { get; set; }
5252

53+
/// <summary>
54+
/// Will be set to true once the invite has met the authorisation requirements.
55+
/// </summary>
56+
public bool IsAuthorised { get; set; }
57+
5358
public UserInviteStatusEnum Status
5459
{
5560
get
5661
{
62+
if(!IsAuthorised)
63+
{
64+
return UserInviteStatusEnum.AuthorisationRequired;
65+
}
66+
5767
if (UserID != null)
5868
{
5969
return UserInviteStatusEnum.Accepted;
@@ -69,4 +79,20 @@ public UserInviteStatusEnum Status
6979
}
7080
}
7181
}
82+
83+
/// <summary>
84+
/// Gets a hash of the critical fields for the user invite. This hash is
85+
/// used to ensure a user invite's details are not modified between the time the
86+
/// authorisation is given and the time the user invite is enabled.
87+
/// </summary>
88+
/// <returns>A hash of the user invite's critical fields.</returns>
89+
public string GetApprovalHash()
90+
{
91+
var input =
92+
InviteeEmailAddress +
93+
MerchantID +
94+
InitialRoleID?.ToString();
95+
96+
return HashHelper.CreateHash(input);
97+
}
7298
}

src/NoFrixion.MoneyMoov/MoneyMoovUrlBuilder.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,6 @@ public static string MerchantTokensUrl(string moneyMoovBaseUrl, Guid merchantID)
124124

125125
public static string MerchantUserInvitesUrl(string moneyMoovBaseUrl, Guid merchantID)
126126
=> $"{moneyMoovBaseUrl}/{MoneyMoovResources.merchants}/{merchantID}/{MoneyMoovResources.userinvites}";
127-
128-
public static string MerchantUserRolesUrl(string moneyMoovBaseUrl, Guid merchantID)
129-
=> $"{moneyMoovBaseUrl}/{MoneyMoovResources.merchants}/{merchantID}/{MoneyMoovResources.userroles}";
130-
131-
public static string MerchantUserRoleUrl(string moneyMoovBaseUrl)
132-
=> $"{moneyMoovBaseUrl}/{MoneyMoovResources.merchants}/{MoneyMoovResources.userroles}";
133127

134128
public static string MerchantWebHooksUrl(string moneyMoovBaseUrl, Guid merchantID)
135129
=> $"{moneyMoovBaseUrl}/{MoneyMoovResources.merchants}/{merchantID}/{MoneyMoovResources.webhooks}";

0 commit comments

Comments
 (0)