Exemplo n.º 1
0
        public async Task <T> Delete(string webApi)
        {
            string baseUrl = BaseRestService.GetConnectionStringByName(false);

            using (RestService <T> restService = new RestService <T>(baseUrl))
            {
                return(await restService.DELETEAsync(webApi));
            }
        }
Exemplo n.º 2
0
        public async Task <T> GetById(string webApi)
        {
            string baseUrl = BaseRestService.GetConnectionStringByName(false);

            using (RestService <T> restService = new RestService <T>(baseUrl))
            {
                return(await restService.POSTAsync(webApi, null, false));
            }
        }
Exemplo n.º 3
0
        public async Task <bool> DeleteAuthor(int id)
        {
            string baseUrl = BaseRestService.GetConnectionStringByName(false);

            using (RestService <bool> restService = new RestService <bool>(baseUrl))
            {
                return(await restService.DELETEAsync(webApi));
            }
        }
Exemplo n.º 4
0
        public async Task <IEnumerable <AuthorListDTO> > GetAllAuthors()
        {
            string baseUrl = BaseRestService.GetConnectionStringByName(false);

            using (RestService <IEnumerable <AuthorListDTO> > restService = new RestService <IEnumerable <AuthorListDTO> >(baseUrl))
            {
                return(await restService.GETAsync(webApi));
            }
        }
Exemplo n.º 5
0
        public async Task <bool> CreateAuthor(AuthorDTO author, bool isNewItem)
        {
            string baseUrl = BaseRestService.GetConnectionStringByName(false);

            using RestService <bool> restService = new RestService <bool>(baseUrl);
            if (isNewItem)
            {
                return(await restService.POSTAsync(webApi, author, false));
            }
            else
            {
                return(await restService.POSTAsync(webApi, author, true));
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Instantiate a new Scryfall API client.
        /// </summary>
        /// <param name="httpClient"></param>
        /// <param name="clientConfig"></param>
        /// <param name="cache"></param>
        public ScryfallApiClient(HttpClient httpClient, ScryfallApiClientConfig clientConfig = null, IMemoryCache cache = null)
        {
            if (clientConfig is null)
            {
                clientConfig = ScryfallApiClientConfig.GetDefault();
                clientConfig.EnableCaching = cache is not null;
            }

            var restService = new BaseRestService(httpClient, clientConfig, cache);

            _cards     = new Lazy <ICards>(() => new Cards(restService));
            _catalogs  = new Lazy <ICatalogs>(() => new Catalogs(restService));
            _sets      = new Lazy <ISets>(() => new Sets(restService));
            _symbology = new Lazy <ISymbology>(() => new Symbology(restService));
        }
Exemplo n.º 7
0
        public async Task <T> Create(T entity, bool isNewItem, string webApi)
        {
            string baseUrl = BaseRestService.GetConnectionStringByName(false);

            using (RestService <T> restService = new RestService <T>(baseUrl))
            {
                if (isNewItem)
                {
                    return(await restService.POSTAsync(webApi, entity, false));
                }
                else
                {
                    return(await restService.POSTAsync(webApi, entity, true));
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public HttpRequestMessage CreateRequest(BaseRestService service)
        {
            HttpRequestMessage request = new HttpRequestMessage(new HttpMethod(StringValueAttribute.GetStringValue(this.HttpMethod)), BuildUrl());

            request.Headers.Authorization = new AuthenticationHeaderValue("Basic", Utilities.EncodeCredentials(service.Credentials.ApiKey, service.Credentials.SecretKey));
            request.Headers.Add("Y-Client-Type", ".NET");
            request.Headers.Add("Y-Client-Info", service.GetType().GetTypeInfo().Assembly.FullName);

#if NETSTANDARD1_3
            request.Headers.Add("Y-Client-Platform", System.Runtime.InteropServices.RuntimeInformation.OSDescription);
#else
            request.Headers.Add("Y-Client-Platform", System.Environment.OSVersion.ToString());
#endif

            if (service.CustomHeaders != null && service.CustomHeaders.Count > 0)
            {
                foreach (var customHeader in service.CustomHeaders)
                {
                    request.Headers.Add(customHeader.Key, customHeader.Value);
                }
            }

            return(request);
        }
Exemplo n.º 9
0
 /// <summary>
 /// Constructs a new request.
 /// </summary>
 /// <param name="service"></param>
 /// <param name="body"></param>
 public SubmitRecordsServiceRequest(BaseRestService service, SubmitRecordsRequest body) : base(service)
 {
     _body = body;
 }
 /// <summary>
 /// Constructs a new request.
 /// </summary>
 /// <param name="service"></param>
 /// <param name="body"></param>
 public DeleteRecordsServiceRequest(BaseRestService service, DeleteRecordsRequest body) : base(service)
 {
     _body = body;
 }
Exemplo n.º 11
0
 internal Symbology(BaseRestService restService)
 {
     _restService = restService;
 }
Exemplo n.º 12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="service"></param>
 public WorkflowServiceRequest(BaseRestService service) : base(service)
 {
 }
Exemplo n.º 13
0
 internal Catalogs(BaseRestService restService)
 {
     _restService = restService;
 }
Exemplo n.º 14
0
 internal BulkData(BaseRestService restService)
 {
     _restService = restService;
 }
Exemplo n.º 15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="service"></param>
 public SmppServiceRequest(BaseRestService service) : base(service)
 {
 }
Exemplo n.º 16
0
 /// <summary>
 /// Constructs a new RestClientServiceRequest.
 /// </summary>
 /// <param name="service">Service</param>
 public RestClientServiceRequest(BaseRestService service)
 {
     _service = service;
 }
Exemplo n.º 17
0
 internal Sets(BaseRestService restService)
 {
     _restService = restService;
 }
 /// <summary>
 /// Constructs a new request.
 /// </summary>
 /// <param name="service"></param>
 /// <param name="body"></param>
 public QueryRecordsServiceRequest(BaseRestService service, QueryRecordsRequest body) : base(service)
 {
     _body = body;
 }
Exemplo n.º 19
0
 internal Cards(BaseRestService restService)
 {
     _restService = restService;
 }
Exemplo n.º 20
0
 /// <summary>
 /// Constructs a new RemoteSimServiceRequest.
 /// </summary>
 /// <param name="service"></param>
 /// <param name="body"></param>
 public RemoteSimServiceRequest(BaseRestService service, RemoteSimRequest body) : base(service)
 {
     _body = body;
 }