コード例 #1
0
 public void ChangeRoute(string route)
 {
     request.Url = Device.RuntimePlatform == Device.Android
         ? AppResources.ApiUrlAndroid
         : AppResources.ApiUrl;
     request.AppendPathSegment(route);
 }
コード例 #2
0
 public Search(IFlurlRequest req, string searchTerm, int page, string[] searchCategory, string[] searchFilter)
 {
     this.req            = req;
     this.searchTerm     = searchTerm;
     this.page           = page;
     this.searchCategory = searchCategory;
     this.searchFilter   = searchFilter;
     req
     .AppendPathSegment("search")
     .SetQueryParam("searchTerm", searchTerm)
     .SetQueryParam("searchCategory", "all")
     .SetQueryParam("searchFilters", "[]")
     .SetQueryParam("page", page);
 }
コード例 #3
0
        public async Task <bool> CreateAsync(Action <IndexInfo <TSource> > index,
                                             CancellationToken cancellationToken = default)
        {
            object message = _createMessage(index);

            IFlurlRequest     request  = _database.NewRequest();
            IndexSaveResponse response = await request
                                         .AppendPathSegment("_index")
                                         .PostJsonAsync(message, cancellationToken)
                                         .ReceiveJson <IndexSaveResponse>()
                                         .SendRequestAsync()
                                         .ConfigureAwait(false);

            return("created" == response.Result);
        }
コード例 #4
0
        public async Task <bool> CreateOrUpdateAsync(Action <IndexInfo <TSource> > index,
                                                     CancellationToken cancellationToken = default)
        {
            IFlurlRequest       request  = _database.NewRequest();
            IndexDesignResponse response = await request
                                           .AppendPathSegment("_index")
                                           .GetJsonAsync <IndexDesignResponse>()
                                           .SendRequestAsync()
                                           .ConfigureAwait(false);

            var message      = _createMessage(index);
            var currentIndex = response.Indexes.FirstOrDefault(x => x.Name == message.Name);

            if (currentIndex != null)
            {
                await Delete(currentIndex.DDoc, currentIndex.Name, cancellationToken).ConfigureAwait(false);
            }

            return(await CreateAsync(index, cancellationToken).ConfigureAwait(false));
        }
コード例 #5
0
        public async Task <T> GetById <T>(object id)
        {
            IFlurlRequest request = getPath();

            return(await request.AppendPathSegment($"/{id}").GetJsonAsync <T>());
        }
コード例 #6
0
 public void ChangeRoute(string route)
 {
     request.Url = Settings.Default.ApiUrl;
     request.AppendPathSegment(route);
 }