コード例 #1
0
        public static ApiClientOneVoucherRedeemResponse GetApiClientOneVoucher(ApiClientOneVoucherRedeemFilter data, string token)
        {
            IRestRequest request = new RestRequest("partner/1voucher-redemption/1.0.0/voucher/redeem", Method.POST);

            request.AddHeader("Accept", "application/json");
            request.AddHeader("Authorization", $"Bearer {token}");
            request.AddJsonBody(data);
            var response = RestFlash.Execute <ApiClientOneVoucherRedeemResponse>(request);

            if (response.StatusCode != HttpStatusCode.OK)
            {
                if (response.StatusCode != HttpStatusCode.Accepted)
                {
                    throw new Exception(response.StatusDescription, new Exception(response.Content));
                }
            }
            return(response.Data);
        }
コード例 #2
0
        public static FlashTokenResponse RefreshTokenAsync(string token)
        {
            IRestRequest request = new RestRequest("/token", Method.POST);

            request.AddHeader("content-type", "application/x-www-form-urlencoded");
            request.AddHeader("Authorization", $"Basic {Config.FlashConsumerSecretKey}");
            request.AddParameter("grant_type", "refresh_token");
            request.AddParameter("refresh_token", token);
            var response = RestFlash.Execute <FlashTokenResponse>(request);

            if (response.StatusCode != HttpStatusCode.OK)
            {
                if (response.StatusCode != HttpStatusCode.Accepted)
                {
                    throw new Exception(response.StatusDescription, new Exception(response.Content));
                }
            }
            return(response.Data);
        }