Exemplo n.º 1
0
		public async Task<IResponseResult<IPaginationCollection<T>>> GetAsync(
			TokenBase token, 
			int? skip = null, 
			int? limit = null, 
			bool? withCount = null, 
			string orderBy = null, 
			SortDirection? sortDirection = null,
			string searchKeyword = null)
		{
			if (string.IsNullOrEmpty(searchKeyword) || string.IsNullOrEmpty(searchKeyword.Trim()))
			{
				return await this.ExecuteRequestAsync<PaginationCollection<T>>(
					HttpMethod.Get, 
					$"{this.BaseUrl}/memberships/{this.MembershipId}/{this.Slug}", 
					QueryStringHelper.GetQueryString(skip, limit, withCount, orderBy, sortDirection), 
					HeaderCollection.Add("Authorization", token.ToString()));
			}
			else
			{
				return await this.ExecuteRequestAsync<PaginationCollection<T>>(
					HttpMethod.Get, 
					$"{this.BaseUrl}/memberships/{this.MembershipId}/{this.Slug}/search", 
					QueryStringHelper.GetQueryString(skip, limit, withCount, orderBy, sortDirection).Add("keyword", searchKeyword), 
					HeaderCollection.Add("Authorization", token.ToString()));
			}
		}
Exemplo n.º 2
0
		public async Task<IResponseResult<T>> GetAsync(string modelId, TokenBase token)
		{
			return await this.ExecuteRequestAsync<T>(
				HttpMethod.Get, 
				$"{this.BaseUrl}/memberships/{this.MembershipId}/{this.Slug}/{modelId}", 
				null, 
				HeaderCollection.Add("Authorization", token.ToString()));
		}
Exemplo n.º 3
0
 public async Task <IResponseResult <Application> > GetApplicationAsync(string id, TokenBase token)
 {
     return(await this.ExecuteRequestAsync <Application>(
                HttpMethod.Get,
                $"{this.AuthApiBaseUrl}/memberships/{this.AuthApiMembershipId}/applications/{id}",
                null,
                HeaderCollection.Add("Authorization", token.ToString())));
 }
Exemplo n.º 4
0
 public async Task <IResponseResult> DeleteMembershipAsync(string membershipId, TokenBase token)
 {
     return(await this.ExecuteRequestAsync <Membership>(
                HttpMethod.Delete,
                $"{this.AuthApiBaseUrl}/memberships/{membershipId}",
                null,
                HeaderCollection.Add("Authorization", token.ToString())));
 }
Exemplo n.º 5
0
        public async Task <bool> CheckPermissionAsync(string rbac, TokenBase token)
        {
            var url         = $"{this.AuthApiBaseUrl}/memberships/{this.AuthApiMembershipId}/roles/check-permission";
            var queryString = QueryString.Add("permission", rbac);
            var headers     = HeaderCollection.Add("Authorization", token.ToString());
            var response    = await this.ExecuteRequestAsync(HttpMethod.Get, url, queryString, headers);

            return(response.IsSuccess);
        }
Exemplo n.º 6
0
 public async Task <IResponseResult <Membership> > CreateMembershipAsync(Membership membership, TokenBase token)
 {
     return(await this.ExecuteRequestAsync <Membership>(
                HttpMethod.Post,
                $"{this.AuthApiBaseUrl}/memberships",
                null,
                HeaderCollection.Add("Authorization", token.ToString()),
                new JsonRequestBody(membership)));
 }
Exemplo n.º 7
0
 public async Task <IResponseResult> SetPasswordAsync(string email, string password, string resetToken, TokenBase token)
 {
     return(await this.ExecuteRequestAsync(
                HttpMethod.Post,
                $"{this.BaseUrl}/memberships/{this.MembershipId}/users/set-password",
                null,
                HeaderCollection.Add("Authorization", token.ToString()),
                new JsonRequestBody(new { email_address = email, reset_token = resetToken, password })));
 }
Exemplo n.º 8
0
 public async Task <IResponseResult> ChangePasswordAsync(string userId, string newPassword, TokenBase token)
 {
     return(await this.ExecuteRequestAsync(
                HttpMethod.Put,
                $"{this.BaseUrl}/memberships/{this.MembershipId}/users/{userId}/change-password",
                null,
                HeaderCollection.Add("Authorization", token.ToString()),
                new JsonRequestBody(new { password = newPassword })));
 }
Exemplo n.º 9
0
        public async Task <IResponseResult <Membership> > UpdateMembershipAsync(Membership membership, TokenBase token)
        {
            if (string.IsNullOrEmpty(membership.Id))
            {
                return(new ResponseResult <Membership>(false, "Membership id is required!"));
            }

            return(await this.ExecuteRequestAsync <Membership>(
                       HttpMethod.Put,
                       $"{this.AuthApiBaseUrl}/memberships/{membership.Id}",
                       null,
                       HeaderCollection.Add("Authorization", token.ToString()),
                       new JsonRequestBody(membership)));
        }
Exemplo n.º 10
0
 public async Task <IResponseResult <ResetPasswordToken> > ResetPasswordAsync(string emailAddress, string server, string host, TokenBase token)
 {
     return(await this.ExecuteRequestAsync <ResetPasswordToken>(
                HttpMethod.Post,
                $"{this.BaseUrl}/memberships/{this.MembershipId}/users/reset-password",
                null,
                HeaderCollection.Add("Authorization", token.ToString()),
                new JsonRequestBody(new
     {
         email_address = emailAddress,
         server,
         host
     })));
 }
Exemplo n.º 11
0
		public async Task<IResponseResult<IPaginationCollection<T>>> QueryAsync(
			TokenBase token,
			string query,
			int? skip = null,
			int? limit = null,
			bool? withCount = null,
			string orderBy = null,
			SortDirection? sortDirection = null)
		{
			return await this.ExecuteRequestAsync<PaginationCollection<T>>(
				HttpMethod.Post, 
				$"{this.BaseUrl}/memberships/{this.MembershipId}/{this.Slug}/_query", 
				QueryStringHelper.GetQueryString(skip, limit, withCount, orderBy, sortDirection), 
				HeaderCollection.Add("Authorization", token.ToString()),
				new JsonRequestBody(Newtonsoft.Json.JsonConvert.DeserializeObject(query)));
		}
Exemplo n.º 12
0
        public async Task <IResponseResult <ErtisAuthCustomEvent> > FireCustomEventAsync(string eventType, string utilizerId, object document, object prior, TokenBase token)
        {
            var ertisAuthCustomEvent = new ErtisAuthCustomEvent
            {
                EventType    = eventType,
                UtilizerId   = utilizerId,
                Document     = document,
                Prior        = prior,
                MembershipId = this.MembershipId
            };

            return(await this.ExecuteRequestAsync <ErtisAuthCustomEvent>(
                       HttpMethod.Post,
                       $"{this.BaseUrl}/memberships/{this.MembershipId}/events",
                       null,
                       HeaderCollection.Add("Authorization", token.ToString()),
                       new JsonRequestBody(ertisAuthCustomEvent)));
        }
Exemplo n.º 13
0
        public async Task <IResponseResult <IPaginationCollection <RevokedToken> > > GetRevokedTokensAsync(
            string userId,
            TokenBase token,
            int?skip       = null,
            int?limit      = null,
            bool?withCount = null,
            string orderBy = null,
            SortDirection?sortDirection = null)
        {
            var query = "{ 'where': { 'user_id': '" + userId + "', 'membership_id': '" + this.MembershipId + "', 'token_type': 'bearer_token' } }";

            return(await this.ExecuteRequestAsync <PaginationCollection <RevokedToken> >(
                       HttpMethod.Post,
                       $"{this.BaseUrl}/memberships/{this.MembershipId}/revoked-tokens/_query",
                       QueryStringHelper.GetQueryString(skip, limit, withCount, orderBy, sortDirection),
                       HeaderCollection.Add("Authorization", token.ToString()),
                       new JsonRequestBody(Newtonsoft.Json.JsonConvert.DeserializeObject(query))));
        }