예제 #1
0
        /// <summary>
        /// 구매 취소
        /// </summary>
        /// <param name="aReceiptId"></param>
        /// <returns></returns>
        public static DTOPurchaseCancelResponse API_PatchPurchaseCancel(string aRfid, string aReceiptId)
        {
            //----------------------------------------
            DTOPurchaseCancelRequest req = new DTOPurchaseCancelRequest();

            {
                req.rfid = aRfid;
            }

            //----------------------------------------
            RestSharp.RestClient  client  = new RestSharp.RestClient(URL_DCCAFFE);
            RestSharp.RestRequest request = new RestSharp.RestRequest();
            request.AddHeader("Content-Type", "application/json;charset=UTF-8");

            request.Method        = RestSharp.Method.PATCH;
            request.RequestFormat = RestSharp.DataFormat.Json;
            request.Resource      = URI_PATCH_PURCHASE_CANCEL;

            request.AddParameter("receipt_id", aReceiptId, RestSharp.ParameterType.UrlSegment);
            request.AddJsonBody(req);

            //----------------------------------------
            var t1 = client.ExecuteTaskAsync(request);

            t1.Wait();

            //----------------------------------------
            // error handling
            if (t1.Result.ErrorException != null)
            {
                System.Diagnostics.Debug.WriteLine("[RESPONSE] " + t1.Result.Content);
                return(null);
            }

            string json = t1.Result.Content;

            //----------------------------------------
            // debug output
            json = JsonFormatting(json);
            System.Diagnostics.Debug.WriteLine("[RESPONSE] " + json);

            //----------------------------------------
            // desirialized json data
            DTOPurchaseCancelResponse dto = new DTOPurchaseCancelResponse();

            try
            {
                dto      = JsonConvert.DeserializeObject <DTOPurchaseCancelResponse>(json);
                dto.code = (int)t1.Result.StatusCode;
            }
            catch (Exception ex)
            {
                dto = null;
                System.Diagnostics.Debug.WriteLine("[ERROR] " + ex.Message);
            }

            return(dto);
        }
예제 #2
0
        private void Action_API_PatchPurchaseCancel()
        {
            System.Threading.Thread.Sleep(2000);

            // 취소 요청
            rsp = APIController.API_PatchPurchaseCancel(XRfid, this.label_Display.Text);

            // 외부에서 결과 내용 사용하도록 노출
            XApiResponse = rsp;
        }