/// <summary> /// Accepts loss on a dispute. Square returns /// the disputed amount to the cardholder and updates the /// dispute state to ACCEPTED. /// Square debits the disputed amount from the seller’s Square /// account. If the Square account balance does not have /// sufficient funds, Square debits the associated bank account. /// </summary> /// <param name="disputeId">Required parameter: ID of the dispute you want to accept.</param> /// <return>Returns the Models.AcceptDisputeResponse response from the API call</return> public async Task <Models.AcceptDisputeResponse> AcceptDisputeAsync(string disputeId, CancellationToken cancellationToken = default) { //the base uri for api requests string _baseUri = config.GetBaseUri(); //prepare query string for API call StringBuilder _queryBuilder = new StringBuilder(_baseUri); _queryBuilder.Append("/v2/disputes/{dispute_id}/accept"); //process optional template parameters ApiHelper.AppendUrlWithTemplateParameters(_queryBuilder, new Dictionary <string, object>() { { "dispute_id", disputeId } }); //append request with appropriate headers and parameters var _headers = new Dictionary <string, string>() { { "user-agent", userAgent }, { "accept", "application/json" }, { "Square-Version", config.SquareVersion } }; //prepare the API call request to fetch the response HttpRequest _request = GetClientInstance().Post(_queryBuilder.ToString(), _headers, null); if (HttpCallBack != null) { HttpCallBack.OnBeforeHttpRequestEventHandler(GetClientInstance(), _request); } _request = await authManagers["global"].ApplyAsync(_request).ConfigureAwait(false); //invoke request and get response HttpStringResponse _response = await GetClientInstance().ExecuteAsStringAsync(_request, cancellationToken).ConfigureAwait(false); HttpContext _context = new HttpContext(_request, _response); if (HttpCallBack != null) { HttpCallBack.OnAfterHttpResponseEventHandler(GetClientInstance(), _response); } //handle errors defined at the API level base.ValidateResponse(_response, _context); var _responseModel = ApiHelper.JsonDeserialize <Models.AcceptDisputeResponse>(_response.Body); _responseModel.Context = _context; return(_responseModel); }
/// <summary> /// Revokes an access token generated with the OAuth flow. /// If an account has more than one OAuth access token for your application, this /// endpoint revokes all of them, regardless of which token you specify. When an /// OAuth access token is revoked, all of the active subscriptions associated /// with that OAuth token are canceled immediately. /// __Important:__ The `Authorization` header for this endpoint must have the /// following format: /// ``` /// Authorization: Client APPLICATION_SECRET /// ``` /// Replace `APPLICATION_SECRET` with the application secret on the Credentials /// page in the [application dashboard](https://connect.squareup.com/apps). /// </summary> /// <param name="body">Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details.</param> /// <param name="authorization">Required parameter: Client APPLICATION_SECRET</param> /// <return>Returns the Models.RevokeTokenResponse response from the API call</return> public async Task <Models.RevokeTokenResponse> RevokeTokenAsync(Models.RevokeTokenRequest body, string authorization, CancellationToken cancellationToken = default) { //the base uri for api requests string _baseUri = config.GetBaseUri(); //prepare query string for API call StringBuilder _queryBuilder = new StringBuilder(_baseUri); _queryBuilder.Append("/oauth2/revoke"); //validate and preprocess url string _queryUrl = ApiHelper.CleanUrl(_queryBuilder); //append request with appropriate headers and parameters var _headers = new Dictionary <string, string>() { { "user-agent", userAgent }, { "accept", "application/json" }, { "content-type", "application/json; charset=utf-8" }, { "Authorization", authorization }, { "Square-Version", "2020-06-25" } }; //append body params var _body = ApiHelper.JsonSerialize(body); //prepare the API call request to fetch the response HttpRequest _request = GetClientInstance().PostBody(_queryUrl, _headers, _body); if (HttpCallBack != null) { HttpCallBack.OnBeforeHttpRequestEventHandler(GetClientInstance(), _request); } //invoke request and get response HttpStringResponse _response = await GetClientInstance().ExecuteAsStringAsync(_request, cancellationToken).ConfigureAwait(false); HttpContext _context = new HttpContext(_request, _response); if (HttpCallBack != null) { HttpCallBack.OnAfterHttpResponseEventHandler(GetClientInstance(), _response); } //handle errors defined at the API level base.ValidateResponse(_response, _context); var _responseModel = ApiHelper.JsonDeserialize <Models.RevokeTokenResponse>(_response.Body); _responseModel.Context = _context; return(_responseModel); }
public async Task<Models.RetrieveTransactionResponse> RetrieveTransactionAsync(string locationId, string transactionId, CancellationToken cancellationToken = default) { //the base uri for api requests string _baseUri = config.GetBaseUri(); //prepare query string for API call StringBuilder _queryBuilder = new StringBuilder(_baseUri); _queryBuilder.Append("/v2/locations/{location_id}/transactions/{transaction_id}"); //process optional template parameters ApiHelper.AppendUrlWithTemplateParameters(_queryBuilder, new Dictionary<string, object>() { { "location_id", locationId }, { "transaction_id", transactionId } }); //validate and preprocess url string _queryUrl = ApiHelper.CleanUrl(_queryBuilder); //append request with appropriate headers and parameters var _headers = new Dictionary<string, string>() { { "user-agent", userAgent }, { "accept", "application/json" }, { "Square-Version", "2020-03-25" } }; //prepare the API call request to fetch the response HttpRequest _request = GetClientInstance().Get(_queryUrl,_headers); if (HttpCallBack != null) { HttpCallBack.OnBeforeHttpRequestEventHandler(GetClientInstance(), _request); } _request = await authManagers["default"].ApplyAsync(_request).ConfigureAwait(false); //invoke request and get response HttpStringResponse _response = await GetClientInstance().ExecuteAsStringAsync(_request, cancellationToken).ConfigureAwait(false); HttpContext _context = new HttpContext(_request, _response); if (HttpCallBack != null) { HttpCallBack.OnAfterHttpResponseEventHandler(GetClientInstance(), _response); } //handle errors defined at the API level base.ValidateResponse(_response, _context); var _responseModel = ApiHelper.JsonDeserialize<Models.RetrieveTransactionResponse>(_response.Body); _responseModel.Context = _context; return _responseModel; }
/// <summary> /// TODO: type endpoint description here /// </summary> /// <return>Returns the string response from the API call</return> public async Task <string> GetCustomHeaderSignatureAsync() { //the base uri for api requests string _baseUri = config.GetBaseURI(); //prepare query string for API call StringBuilder _queryBuilder = new StringBuilder(_baseUri); _queryBuilder.Append("/auth/customHeaderSignature"); //validate and preprocess url string _queryUrl = APIHelper.CleanUrl(_queryBuilder); //append request with appropriate headers and parameters var _headers = new Dictionary <string, string>() { { "user-agent", "APIMATIC 2.0" } }; _headers.Add("token", config.Token); //prepare the API call request to fetch the response HttpRequest _request = GetClientInstance().Get(_queryUrl, _headers); if (HttpCallBack != null) { HttpCallBack.OnBeforeHttpRequestEventHandler(GetClientInstance(), _request); } //invoke request and get response HttpStringResponse _response = (HttpStringResponse) await GetClientInstance().ExecuteAsStringAsync(_request).ConfigureAwait(false); HttpContext _context = new HttpContext(_request, _response); if (HttpCallBack != null) { HttpCallBack.OnAfterHttpResponseEventHandler(GetClientInstance(), _response); } //handle errors defined at the API level ValidateResponse(_response, _context); try { return(_response.Body); } catch (Exception _ex) { throw new APIException("Failed to parse the response: " + _ex.Message, _context); } }
/// <summary> /// Searches for availabilities for booking. /// </summary> /// <param name="body">Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details.</param> /// <return>Returns the Models.SearchAvailabilityResponse response from the API call</return> public async Task <Models.SearchAvailabilityResponse> SearchAvailabilityAsync(Models.SearchAvailabilityRequest body, CancellationToken cancellationToken = default) { //the base uri for api requests string _baseUri = config.GetBaseUri(); //prepare query string for API call StringBuilder _queryBuilder = new StringBuilder(_baseUri); _queryBuilder.Append("/v2/bookings/availability/search"); //append request with appropriate headers and parameters var _headers = new Dictionary <string, string>() { { "user-agent", userAgent }, { "accept", "application/json" }, { "content-type", "application/json; charset=utf-8" }, { "Square-Version", config.SquareVersion } }; //append body params var _body = ApiHelper.JsonSerialize(body); //prepare the API call request to fetch the response HttpRequest _request = GetClientInstance().PostBody(_queryBuilder.ToString(), _headers, _body); if (HttpCallBack != null) { HttpCallBack.OnBeforeHttpRequestEventHandler(GetClientInstance(), _request); } _request = await authManagers["global"].ApplyAsync(_request).ConfigureAwait(false); //invoke request and get response HttpStringResponse _response = await GetClientInstance().ExecuteAsStringAsync(_request, cancellationToken).ConfigureAwait(false); HttpContext _context = new HttpContext(_request, _response); if (HttpCallBack != null) { HttpCallBack.OnAfterHttpResponseEventHandler(GetClientInstance(), _response); } //handle errors defined at the API level base.ValidateResponse(_response, _context); var _responseModel = ApiHelper.JsonDeserialize <Models.SearchAvailabilityResponse>(_response.Body); _responseModel.Context = _context; return(_responseModel); }
void ResultCallBack(HttpCallBack callBack, string result) { if (callBack.Method.IsStatic) { callBack(result); return; } if (callBack.Target.ToString() == "null") { SQDebug.LogWarning("Object was destroyed, but it always wanna to be handle"); return; } callBack(result); }
public static void SendPost(string url, WWWForm form, HttpCallBack callBack = null) { if (Instance == null || Instance.gameObject.activeSelf == false) { SQDebug.Log("Instance is null or active self == false,please send wait" + url); return; } // Dictionary <string, string> header = new Dictionary <string, string>(); // Instance.StartCoroutine(Instance.PostData(url, form, header, callBack)); }
internal static void getVideoInfo(long id, HttpCallBack call) { Dictionary <string, string> param = new Dictionary <string, string>(); param.Add("appkey", "buildkey"); param.Add("aid", id.ToString()); param.Add("build", "0"); param.Add("mobi_app", "android"); param.Add("autoplay", "1"); param.Add("ts", Utils.getUnixStamp.ToString()); HTTPRequest <VideoInfo>("https://app.bilibili.com/x/v2/view", param, call); }
/// <summary> /// Post方法将资源上传到服务器,资源类型文件 /// </summary> /// <param name="httpUrl">服务器地址</param> /// <param name="filePath">资源文件路径</param> /// <param name="callBack">回调函数</param> /// <param name="Corece">关闭之前的协程,强制执行新请求</param> /// <param name="parameters">回调携带的参数</param> public void Post(string httpUrl, string filePath, string fileName = "data", HttpCallBack callBack = null, bool Corece = false, object[] parameters = null) { if (!File.Exists(filePath)) { ErrorMessage("Error: 不存在该文件,请检查! 参数:" + filePath); return; } Stream st = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read); byte[] itemByte = new byte[st.Length]; st.Read(itemByte, 0, itemByte.Length); st.Close(); Post(httpUrl, itemByte, fileName, callBack, Corece, parameters); }
public async Task <List <Models.V1Merchant> > ListLocationsAsync(CancellationToken cancellationToken = default) { //the base uri for api requests string _baseUri = config.GetBaseUri(); //prepare query string for API call StringBuilder _queryBuilder = new StringBuilder(_baseUri); _queryBuilder.Append("/v1/me/locations"); //validate and preprocess url string _queryUrl = ApiHelper.CleanUrl(_queryBuilder); //append request with appropriate headers and parameters var _headers = new Dictionary <string, string>() { { "user-agent", userAgent }, { "accept", "application/json" }, { "Square-Version", "2020-05-28" } }; //prepare the API call request to fetch the response HttpRequest _request = GetClientInstance().Get(_queryUrl, _headers); if (HttpCallBack != null) { HttpCallBack.OnBeforeHttpRequestEventHandler(GetClientInstance(), _request); } _request = await authManagers["default"].ApplyAsync(_request).ConfigureAwait(false); //invoke request and get response HttpStringResponse _response = await GetClientInstance().ExecuteAsStringAsync(_request, cancellationToken).ConfigureAwait(false); HttpContext _context = new HttpContext(_request, _response); if (HttpCallBack != null) { HttpCallBack.OnAfterHttpResponseEventHandler(GetClientInstance(), _response); } //handle errors defined at the API level base.ValidateResponse(_response, _context); var _responseModels = ApiHelper.JsonDeserialize <List <Models.V1Merchant> >(_response.Body); _responseModels.ForEach(r => r.Context = _context); return(_responseModels); }
public PostTask(string Url, HttpCallBack callback, object o, int retryCount = 5, bool IsGetCookie = false) { this.Url = Url; this.CallBack = callback; if (o is string) { this.UpLoadData = o.ToString(); } else { this.UpLoadData = JsonMapper.ToJson(o); } this.RetryCount = retryCount; }
internal static void setFavo(long aid, long fid, string act, HttpCallBack call) { if (Session.SessionToken.Logined) { Dictionary <string, string> param = new Dictionary <string, string>(); param.Add("appkey", "buildkey"); param.Add("aid", aid.ToString()); param.Add("fid", fid.ToString()); param.Add("ts", Utils.getUnixStamp.ToString()); HTTPSRequest <JObject>("https://api.bilibili.com/x/v2/fav/video/" + act, "POST", param, null, call); return; } call(false, "unlogin"); }
internal void getCaptcha(HttpCallBack call) { HTTPSRequest <string>("https://passport.bilibili.com/captcha?_=" + Utils.getUnixStamp, "GET", null, "https://passport.bilibili.com/login", (bool isSuccess, object data) => { if (isSuccess) { ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback((object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) => { return(true); }); HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://passport.bilibili.com/captcha?_=" + Utils.getUnixStamp); req.ProtocolVersion = HttpVersion.Version11; req.ContentType = "application/x-www-form-urlencoded; charset=utf-8"; req.UserAgent = "Mozilla/5.0 BiliDroid/5.32.0 ([email protected])"; req.Headers.Add("Cookie", "JSESSIONID=" + HttpUtils.GetCookie("JSESSIONID", cookie) + "; " + "sid=" + HttpUtils.GetCookie("sid", cookie)); req.Referer = "https://passport.bilibili.com/login"; HttpWebResponse wr = (HttpWebResponse)req.GetResponse(); Stream stream = wr.GetResponseStream(); MemoryStream ms = new MemoryStream(); int bufferLen = 4096; byte[] buffer = new byte[bufferLen]; int bytesCount = 0; while ((bytesCount = stream.Read(buffer, 0, bufferLen)) > 0) { ms.Write(buffer, 0, bytesCount); } stream.Close(); string filePath = Environment.CurrentDirectory + "\\Captcha.jpg"; FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite); byte[] fileBytes = ms.ToArray(); fs.Write(fileBytes, 0, fileBytes.Length); fs.Close(); ms.Close(); BitmapImage captcha = new BitmapImage(); captcha.BeginInit(); captcha.CacheOption = BitmapCacheOption.OnLoad; captcha.UriSource = new Uri(filePath); captcha.EndInit(); captcha.Freeze(); call(true, captcha); } else { call(isSuccess, data); } }); }
internal static void getFavo(long fid, HttpCallBack call) { if (Session.SessionToken.Logined) { Dictionary <string, string> param = new Dictionary <string, string>(); param.Add("appkey", "buildkey"); param.Add("vmid", Session.SessionToken.info.data.mid.ToString()); param.Add("fid", fid.ToString()); param.Add("ts", Utils.getUnixStamp.ToString()); param.Add("order", "ftime"); HTTPSRequest <API.FavoriteInfo>("https://app.bilibili.com/x/v2/favorite/video", "GET", param, null, call); return; } call(false, "unlogin"); }
internal static void sendCoins(long aid, long mid, HttpCallBack call) { if (Session.SessionToken.Logined) { Dictionary <string, string> param = new Dictionary <string, string>(); param.Add("appkey", "buildkey"); param.Add("aid", aid.ToString()); param.Add("mid", mid.ToString()); param.Add("multiply", "1"); param.Add("ts", Utils.getUnixStamp.ToString()); HTTPSRequest <JObject>("https://app.biliapi.com/x/v2/view/coin/add", "POST", param, null, call); return; } call(false, "unlogin"); }
internal static void sendLike(long aid, HttpCallBack call) { if (Session.SessionToken.Logined) { Dictionary <string, string> param = new Dictionary <string, string>(); param.Add("appkey", "buildkey"); param.Add("aid", aid.ToString()); param.Add("dislike", "0"); param.Add("like", "0"); param.Add("ts", Utils.getUnixStamp.ToString()); HTTPSRequest <JObject>("https://app.biliapi.net/x/v2/view/like", "POST", param, null, call); return; } call(false, "unlogin"); }
public void DownLoad(string url, string filePath, HttpHelperCallBack callBack, object data = null) { if (string.IsNullOrEmpty(url) || string.IsNullOrEmpty(filePath)) { if (callBack != null) { callBack(new HttpHelperRet(false, "'url' or 'filePath' is null"), data); } return; } HttpCallBack cb = new HttpCallBack(callBack, data); HttpHelper httpHelper = new HttpHelper(OnDownLoadCallBack, cb); HttpDownLoad dl = new HttpDownLoad(httpHelper, url, filePath); HttpDownLoadList.Add(dl); }
internal static void setHistory(long aid, long cid, HttpCallBack call) { if (Session.SessionToken.Logined) { Dictionary <string, string> param = new Dictionary <string, string>(); param.Add("appkey", "buildkey"); param.Add("aid", aid.ToString()); param.Add("cid", cid.ToString()); param.Add("epid", "0"); param.Add("realtime", "4"); param.Add("type", "3"); HTTPSRequest <JObject>("https://api.bilibili.com/x/v2/history/report", "POST", param, null, call); return; } call(false, "unlogin"); }
public void UpLoad(string url, string filePath, HttpHelperCallBack callBack, object data = null, string userId = "") { if (string.IsNullOrEmpty(filePath) || string.IsNullOrEmpty(url)) { if (callBack != null) { callBack(new HttpHelperRet(false, "'url' or 'filePath' is null"), data); } return; } HttpCallBack cb = new HttpCallBack(callBack, data); HttpHelper httpHelper = new HttpHelper(OnUpLoadCallBack, cb); HttpUpLoad ul = new HttpUpLoad(httpHelper, url, filePath, userId); HttpUpLoadList.Add(ul); }
/// <summary> /// 通用处理初始数据 /// </summary> /// <param name="httpUrl">服务器地址</param> /// <param name="callBack">回调函数</param> /// <param name="parameters">回调携带的参数</param> protected virtual bool InitBaseData(string httpUrl, HttpCallBack callBack, object[] parameters) { if (string.IsNullOrEmpty(httpUrl)) { ErrorMessage("Error: 服务器地址为空,请检查! 参数:" + httpUrl); return(false); } if (m_CoroutinesMono == null) { ErrorMessage("Error: 未初始化方法,请检查! 参数:" + httpUrl); return(false); } Progress = 0; HttpMessage = null; HttpData = null; m_CallBack = callBack; m_HttpUrl = httpUrl; m_Parameters = parameters; return(true); }
internal static void getFavFolder(long aid, HttpCallBack call) { if (Session.SessionToken.Logined) { Dictionary <string, string> param = new Dictionary <string, string>(); param.Add("appkey", "buildkey"); param.Add("aid", aid.ToString()); param.Add("vmid", Session.SessionToken.info.data.mid.ToString()); param.Add("ts", Utils.getUnixStamp.ToString()); HTTPSRequest <JObject>("https://api.bilibili.com/x/v2/fav/folder", "GET", param, null, (bool isSuccess, object data) => { if (isSuccess) { JArray jsonArr = JArray.Parse(((JObject)data)["data"].ToString()); call(true, jsonArr); } }); return; } call(false, "unlogin"); }
private async static void DoHTTPSPost(string url, string data, HttpCallBack call) { UnityEngine.Debug.Log("Post to " + url); HttpWebRequest request; if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase)) { ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback((object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) => { return(true); }); } request = WebRequest.Create(url) as HttpWebRequest; request.Method = "POST"; try { byte[] postData = Encoding.UTF8.GetBytes(data); request.ContentLength = postData.Length; var writer = request.GetRequestStream(); writer.Write(postData, 0, postData.Length); writer.Close(); HttpWebResponse response = await request.GetResponseAsync() as HttpWebResponse; using (StreamReader reader = new StreamReader(response.GetResponseStream())) { string result = reader.ReadToEnd(); response.Close(); call(true, result); } } catch (Exception e) { call(false, e.Message); } }
public async Task <Models.ListRefundsResponse> ListRefundsAsync( string locationId, string beginTime = null, string endTime = null, string sortOrder = null, string cursor = null, CancellationToken cancellationToken = default) { //the base uri for api requests string _baseUri = config.GetBaseUri(); //prepare query string for API call StringBuilder _queryBuilder = new StringBuilder(_baseUri); _queryBuilder.Append("/v2/locations/{location_id}/refunds"); //process optional template parameters ApiHelper.AppendUrlWithTemplateParameters(_queryBuilder, new Dictionary <string, object>() { { "location_id", locationId } }); //process optional query parameters ApiHelper.AppendUrlWithQueryParameters(_queryBuilder, new Dictionary <string, object>() { { "begin_time", beginTime }, { "end_time", endTime }, { "sort_order", sortOrder }, { "cursor", cursor } }, ArrayDeserializationFormat, ParameterSeparator); //validate and preprocess url string _queryUrl = ApiHelper.CleanUrl(_queryBuilder); //append request with appropriate headers and parameters var _headers = new Dictionary <string, string>() { { "user-agent", userAgent }, { "accept", "application/json" }, { "Square-Version", "2020-02-26" } }; //prepare the API call request to fetch the response HttpRequest _request = GetClientInstance().Get(_queryUrl, _headers); if (HttpCallBack != null) { HttpCallBack.OnBeforeHttpRequestEventHandler(GetClientInstance(), _request); } _request = await authManagers["default"].ApplyAsync(_request).ConfigureAwait(false); //invoke request and get response HttpStringResponse _response = await GetClientInstance().ExecuteAsStringAsync(_request, cancellationToken).ConfigureAwait(false); HttpContext _context = new HttpContext(_request, _response); if (HttpCallBack != null) { HttpCallBack.OnAfterHttpResponseEventHandler(GetClientInstance(), _response); } //handle errors defined at the API level base.ValidateResponse(_response, _context); var _responseModel = ApiHelper.JsonDeserialize <Models.ListRefundsResponse>(_response.Body); _responseModel.Context = _context; return(_responseModel); }
internal TransactionsApi(IConfiguration config, IHttpClient httpClient, IDictionary <string, IAuthManager> authManagers, HttpCallBack httpCallBack = null) : base(config, httpClient, authManagers, httpCallBack) { }
IEnumerator PostData(string url, WWWForm form, Dictionary <string, string> header, HttpCallBack callBack = null) { if (isShowLog) { SQDebug.LogWarning(url); } WWW w = new WWW(url, form.data, header); yield return(w); if (!string.IsNullOrEmpty(w.error)) { if (callBack == null) { SQDebug.Log("WWW : " + " erro info " + w.error); yield break; } ResultCallBack(callBack, w.error); yield break; } if (callBack != null) { ResultCallBack(callBack, w.text); } }
public void GetData(string url, HttpCallBack callBack = null) { WWW www = new WWW(url); StartCoroutine(_Send(www, callBack)); }
public void PostData(string url, WWWForm form, HttpCallBack callBack = null) { WWW www = new WWW(url, form); StartCoroutine(_Send(www, callBack)); }
/// <summary> /// Provides summary information for all of a business's employees. /// </summary> /// <param name="order">Optional parameter: The order in which employees are listed in the response, based on their created_at field. Default value: ASC</param> /// <param name="beginUpdatedAt">Optional parameter: If filtering results by their updated_at field, the beginning of the requested reporting period, in ISO 8601 format</param> /// <param name="endUpdatedAt">Optional parameter: If filtering results by there updated_at field, the end of the requested reporting period, in ISO 8601 format.</param> /// <param name="beginCreatedAt">Optional parameter: If filtering results by their created_at field, the beginning of the requested reporting period, in ISO 8601 format.</param> /// <param name="endCreatedAt">Optional parameter: If filtering results by their created_at field, the end of the requested reporting period, in ISO 8601 format.</param> /// <param name="status">Optional parameter: If provided, the endpoint returns only employee entities with the specified status (ACTIVE or INACTIVE).</param> /// <param name="externalId">Optional parameter: If provided, the endpoint returns only employee entities with the specified external_id.</param> /// <param name="limit">Optional parameter: The maximum integer number of employee entities to return in a single response. Default 100, maximum 200.</param> /// <param name="batchToken">Optional parameter: A pagination cursor to retrieve the next set of results for your original query to the endpoint.</param> /// <return>Returns the List<Models.V1Employee> response from the API call</return> public async Task <List <Models.V1Employee> > ListEmployeesAsync( string order = null, string beginUpdatedAt = null, string endUpdatedAt = null, string beginCreatedAt = null, string endCreatedAt = null, string status = null, string externalId = null, int?limit = null, string batchToken = null, CancellationToken cancellationToken = default) { //the base uri for api requests string _baseUri = config.GetBaseUri(); //prepare query string for API call StringBuilder _queryBuilder = new StringBuilder(_baseUri); _queryBuilder.Append("/v1/me/employees"); //prepare specfied query parameters var _queryParameters = new Dictionary <string, object>() { { "order", order }, { "begin_updated_at", beginUpdatedAt }, { "end_updated_at", endUpdatedAt }, { "begin_created_at", beginCreatedAt }, { "end_created_at", endCreatedAt }, { "status", status }, { "external_id", externalId }, { "limit", limit }, { "batch_token", batchToken } }; //append request with appropriate headers and parameters var _headers = new Dictionary <string, string>() { { "user-agent", userAgent }, { "accept", "application/json" }, { "Square-Version", config.SquareVersion } }; //prepare the API call request to fetch the response HttpRequest _request = GetClientInstance().Get(_queryBuilder.ToString(), _headers, queryParameters: _queryParameters); if (HttpCallBack != null) { HttpCallBack.OnBeforeHttpRequestEventHandler(GetClientInstance(), _request); } _request = await authManagers["global"].ApplyAsync(_request).ConfigureAwait(false); //invoke request and get response HttpStringResponse _response = await GetClientInstance().ExecuteAsStringAsync(_request, cancellationToken).ConfigureAwait(false); HttpContext _context = new HttpContext(_request, _response); if (HttpCallBack != null) { HttpCallBack.OnAfterHttpResponseEventHandler(GetClientInstance(), _response); } //handle errors defined at the API level base.ValidateResponse(_response, _context); var _responseModels = ApiHelper.JsonDeserialize <List <Models.V1Employee> >(_response.Body); _responseModels.ForEach(r => r.Context = _context); return(_responseModels); }
internal Builder HttpCallBack(HttpCallBack httpCallBack) { this.httpCallBack = httpCallBack; return(this); }
private SquareClient(TimeSpan timeout, string squareVersion, string accessToken, Environment environment, IDictionary <string, IAuthManager> authManagers, IHttpClient httpClient, HttpCallBack httpCallBack, IDictionary <string, List <string> > additionalHeaders, IHttpClientConfiguration httpClientConfiguration) { Timeout = timeout; SquareVersion = squareVersion; AccessToken = accessToken; Environment = environment; this.httpCallBack = httpCallBack; this.httpClient = httpClient; this.authManagers = new Dictionary <string, IAuthManager>(authManagers); accessTokenManager = new AccessTokenManager(accessToken); this.additionalHeaders = additionalHeaders; HttpClientConfiguration = httpClientConfiguration; mobileAuthorization = new Lazy <IMobileAuthorizationApi>( () => new MobileAuthorizationApi(this, this.httpClient, authManagers, this.httpCallBack)); oAuth = new Lazy <IOAuthApi>( () => new OAuthApi(this, this.httpClient, authManagers, this.httpCallBack)); v1Locations = new Lazy <IV1LocationsApi>( () => new V1LocationsApi(this, this.httpClient, authManagers, this.httpCallBack)); v1Employees = new Lazy <IV1EmployeesApi>( () => new V1EmployeesApi(this, this.httpClient, authManagers, this.httpCallBack)); v1Transactions = new Lazy <IV1TransactionsApi>( () => new V1TransactionsApi(this, this.httpClient, authManagers, this.httpCallBack)); v1Items = new Lazy <IV1ItemsApi>( () => new V1ItemsApi(this, this.httpClient, authManagers, this.httpCallBack)); applePay = new Lazy <IApplePayApi>( () => new ApplePayApi(this, this.httpClient, authManagers, this.httpCallBack)); bankAccounts = new Lazy <IBankAccountsApi>( () => new BankAccountsApi(this, this.httpClient, authManagers, this.httpCallBack)); cashDrawers = new Lazy <ICashDrawersApi>( () => new CashDrawersApi(this, this.httpClient, authManagers, this.httpCallBack)); catalog = new Lazy <ICatalogApi>( () => new CatalogApi(this, this.httpClient, authManagers, this.httpCallBack)); customers = new Lazy <ICustomersApi>( () => new CustomersApi(this, this.httpClient, authManagers, this.httpCallBack)); customerGroups = new Lazy <ICustomerGroupsApi>( () => new CustomerGroupsApi(this, this.httpClient, authManagers, this.httpCallBack)); customerSegments = new Lazy <ICustomerSegmentsApi>( () => new CustomerSegmentsApi(this, this.httpClient, authManagers, this.httpCallBack)); devices = new Lazy <IDevicesApi>( () => new DevicesApi(this, this.httpClient, authManagers, this.httpCallBack)); disputes = new Lazy <IDisputesApi>( () => new DisputesApi(this, this.httpClient, authManagers, this.httpCallBack)); employees = new Lazy <IEmployeesApi>( () => new EmployeesApi(this, this.httpClient, authManagers, this.httpCallBack)); inventory = new Lazy <IInventoryApi>( () => new InventoryApi(this, this.httpClient, authManagers, this.httpCallBack)); invoices = new Lazy <IInvoicesApi>( () => new InvoicesApi(this, this.httpClient, authManagers, this.httpCallBack)); labor = new Lazy <ILaborApi>( () => new LaborApi(this, this.httpClient, authManagers, this.httpCallBack)); locations = new Lazy <ILocationsApi>( () => new LocationsApi(this, this.httpClient, authManagers, this.httpCallBack)); checkout = new Lazy <ICheckoutApi>( () => new CheckoutApi(this, this.httpClient, authManagers, this.httpCallBack)); transactions = new Lazy <ITransactionsApi>( () => new TransactionsApi(this, this.httpClient, authManagers, this.httpCallBack)); loyalty = new Lazy <ILoyaltyApi>( () => new LoyaltyApi(this, this.httpClient, authManagers, this.httpCallBack)); merchants = new Lazy <IMerchantsApi>( () => new MerchantsApi(this, this.httpClient, authManagers, this.httpCallBack)); orders = new Lazy <IOrdersApi>( () => new OrdersApi(this, this.httpClient, authManagers, this.httpCallBack)); payments = new Lazy <IPaymentsApi>( () => new PaymentsApi(this, this.httpClient, authManagers, this.httpCallBack)); refunds = new Lazy <IRefundsApi>( () => new RefundsApi(this, this.httpClient, authManagers, this.httpCallBack)); subscriptions = new Lazy <ISubscriptionsApi>( () => new SubscriptionsApi(this, this.httpClient, authManagers, this.httpCallBack)); team = new Lazy <ITeamApi>( () => new TeamApi(this, this.httpClient, authManagers, this.httpCallBack)); terminal = new Lazy <ITerminalApi>( () => new TerminalApi(this, this.httpClient, authManagers, this.httpCallBack)); if (!authManagers.ContainsKey("default") || ((AccessTokenManager)authManagers["default"]).AccessToken != accessToken) { authManagers["default"] = accessTokenManager; } }