예제 #1
0
        private static TResponse Get <TResponse>(string url, string accessToken, string clientSecret,
                                                 IHtmlScraper scraper = null) where TResponse : ResponseBase, new()
        {
            if (scraper.IsNull())
            {
                scraper = new HtmlScraper();
            }

            RequestHelper.MakeGetRequest(url, accessToken, clientSecret, scraper);

            var response     = scraper.LastContent;
            var deserialized = Deserialize <TResponse>(response);

            return(deserialized);
        }
예제 #2
0
        private static string MakeRequest(string url, string postdata, string accessToken, string clientSecret,
                                          IHtmlScraper scraper)
        {
            var headers = new List <Header>
            {
                new Header {
                    HeaderName = Constants.FortnoxConstants.ACCESS_TOKEN, HeaderValue = accessToken
                },
                new Header {
                    HeaderName = Constants.FortnoxConstants.CLIENT_SECRET, HeaderValue = clientSecret
                }
            };

            return(scraper.PerformRequest(url, postdata, null, Constants.FortnoxConstants.CONTENT_TYPE,
                                          Constants.FortnoxConstants.ACCEPT, headers));
        }
예제 #3
0
        public static Account GetAccount(string accessToken, string clientSecret, string number, IHtmlScraper scraper = null)
        {
            var url = UrlHelper.GetAccount(number);

            return(Get <Account>(url, accessToken, clientSecret, scraper));
        }
예제 #4
0
        public static Accounts GetAllAccounts(string accessToken, string clientSecret, IHtmlScraper scraper = null)
        {
            var url = UrlHelper.GetAllAccounts();

            return(Get <Accounts>(url, accessToken, clientSecret, scraper));
        }
예제 #5
0
 public static string MakeGetRequest(string url, string accessToken, string clientSecret, IHtmlScraper scraper)
 {
     return(MakeRequest(url, null, accessToken, clientSecret, scraper));
 }
예제 #6
0
 public static string MakePostRequest(string url, string postdata, string accessToken, string clientSecret, IHtmlScraper scraper)
 {
     return(MakeRequest(url, postdata, accessToken, clientSecret, scraper));
 }
예제 #7
0
 public CelebRepository()
 {
     _htmlRepository   = new HtmlScraper();
     _serilizeJsonFile = new SerilizeJsonFile();
 }