コード例 #1
0
        /// <summary>
        /// Corresponds to the HTTP Get method.
        /// </summary>
        /// <param name="relativePath">The path to call, relative to the base URI.</param>
        /// <param name="requestHeaders">An optional list of request headers.</param>
        /// <param name="requestParameters">The optional set of request parameters.</param>
        /// <param name="context">The optional call context to use</param>
        /// <typeparam name="T">Type of the response.</typeparam>
        /// <exception cref="CommunicationException"> when an exception occurred communicating with the Ingenico ePayments platform</exception>
        /// <exception cref="ResponseException">when an error response was received from the Ingenico ePayments platform</exception>
        /// <exception cref="ApiException">when an error response was received from the Ingenico ePayments platform which contained a list of errors</exception>
        public async Task <T> Get <T>(string relativePath, IEnumerable <IRequestHeader> requestHeaders, AbstractParamRequest requestParameters,
                                      CallContext context)
        {
            IConnection connection = Session.Connection;
            IEnumerable <RequestParam> requestParameterList = requestParameters?.ToRequestParameters();
            Uri uri = ToAbsoluteURI(relativePath, requestParameterList);

            requestHeaders = requestHeaders ?? new List <IRequestHeader>();
            requestHeaders = AddGenericHeaders(HttpMethod.Get, uri, requestHeaders, context);
            return(await connection.Get <T>(uri, requestHeaders, (status, body, headers) => {
                return ProcessResponse <T>(status, body, headers, relativePath, context);
            }));
        }
コード例 #2
0
        async Task Put(string relativePath, IEnumerable <IRequestHeader> requestHeaders, AbstractParamRequest requestParameters,
                       MultipartFormDataObject multipart, Action <Stream, IEnumerable <IResponseHeader> > bodyHandler, CallContext context)
        {
            IConnection connection = Session.Connection;
            IEnumerable <RequestParam> requestParameterList = requestParameters?.ToRequestParameters();
            Uri uri = ToAbsoluteURI(relativePath, requestParameterList);

            requestHeaders = requestHeaders ?? new List <IRequestHeader>();

            IList <IRequestHeader> requestHeaderList = requestHeaders.ToList();

            requestHeaderList.Add(new EntityHeader("Content-Type", multipart.ContentType));

            requestHeaders = AddGenericHeaders(HttpMethod.Put, uri, requestHeaderList, context);
            await connection.Put(uri, requestHeaders, multipart, (status, body, headers) => {
                return(ProcessResponse <object>(status, body, headers, relativePath, context, bodyHandler));
            });
        }
コード例 #3
0
        /// <summary>
        /// Corresponds to the HTTP PUT method.
        /// </summary>
        /// <param name="relativePath">The path to call, relative to the base URI.</param>
        /// <param name="requestHeaders">An optional list of request headers.</param>
        /// <param name="requestParameters">The optional set of request parameters.</param>
        /// <param name="requestBody">The optional request body to send.</param>
        /// <param name="bodyHandler">A callback that receives the contents of the body as a stream</param>
        /// <param name="context">The optional call context to use</param>
        /// <exception cref="CommunicationException"> when an exception occurred communicating with the Ingenico ePayments platform</exception>
        /// <exception cref="ResponseException">when an error response was received from the Ingenico ePayments platform</exception>
        /// <exception cref="ApiException">when an error response was received from the Ingenico ePayments platform which contained a list of errors</exception>
        /// <exception cref="BodyHandlerException">when the BodyHandler throws an exception</exception>
        public async Task Put(string relativePath, IEnumerable <IRequestHeader> requestHeaders, AbstractParamRequest requestParameters,
                              object requestBody, Action <Stream, IEnumerable <IResponseHeader> > bodyHandler, CallContext context)
        {
            if (requestBody is MultipartFormDataObject)
            {
                await Put(relativePath, requestHeaders, requestParameters, (MultipartFormDataObject)requestBody, bodyHandler, context);

                return;
            }
            if (requestBody is IMultipartFormDataRequest)
            {
                MultipartFormDataObject multipart = ((IMultipartFormDataRequest)requestBody).ToMultipartFormDataObject();
                await Put(relativePath, requestHeaders, requestParameters, multipart, bodyHandler, context);

                return;
            }

            IConnection connection = Session.Connection;
            IEnumerable <RequestParam> requestParameterList = requestParameters?.ToRequestParameters();
            Uri uri = ToAbsoluteURI(relativePath, requestParameterList);

            requestHeaders = requestHeaders ?? new List <IRequestHeader>();

            string requestJson = null;
            IList <IRequestHeader> requestHeaderList = requestHeaders.ToList();

            if (requestBody != null)
            {
                requestHeaderList.Add(new EntityHeader("Content-Type", "application/json"));
                requestJson = Marshaller.Marshal(requestBody);
            }

            requestHeaders = AddGenericHeaders(HttpMethod.Put, uri, requestHeaderList, context);
            await connection.Put(uri, requestHeaders, requestJson, (status, body, headers) => {
                return(ProcessResponse <object>(status, body, headers, relativePath, context, bodyHandler));
            });
        }
コード例 #4
0
        /// <summary>
        /// Corresponds to the HTTP DELETE method.
        /// </summary>
        /// <param name="relativePath">The path to call, relative to the base URI.</param>
        /// <param name="requestHeaders">An optional list of request headers.</param>
        /// <param name="requestParameters">The optional set of request parameters.</param>
        /// <param name="bodyHandler">A callback that receives the contents of the body as a stream</param>
        /// <param name="context">The optional call context to use</param>
        /// <exception cref="CommunicationException"> when an exception occurred communicating with the Ingenico ePayments platform</exception>
        /// <exception cref="ResponseException">when an error response was received from the Ingenico ePayments platform</exception>
        /// <exception cref="ApiException">when an error response was received from the Ingenico ePayments platform which contained a list of errors</exception>
        /// <exception cref="BodyHandlerException">when the BodyHandler throws an exception</exception>
        public async Task Delete(string relativePath, IEnumerable <IRequestHeader> requestHeaders, AbstractParamRequest requestParameters,
                                 Action <Stream, IEnumerable <IResponseHeader> > bodyHandler, CallContext context)
        {
            IConnection connection = Session.Connection;
            IEnumerable <RequestParam> requestParameterList = requestParameters?.ToRequestParameters();
            Uri uri = ToAbsoluteURI(relativePath, requestParameterList);

            requestHeaders = requestHeaders ?? new List <IRequestHeader>();
            requestHeaders = AddGenericHeaders(HttpMethod.Delete, uri, requestHeaders, context);
            await connection.Delete(uri, requestHeaders, (status, body, headers) => {
                return(ProcessResponse <object>(status, body, headers, relativePath, context, bodyHandler));
            });
        }
コード例 #5
0
        /// <summary>
        /// Corresponds to the HTTP DELETE method.
        /// </summary>
        /// <param name="relativePath">The path to call, relative to the base URI.</param>
        /// <param name="requestHeaders">An optional list of request headers.</param>
        /// <param name="requestParameters">The optional set of request parameters.</param>
        /// <param name="context">The optional call context to use</param>
        /// <typeparam name="T">Type of the response.</typeparam>
        /// <exception cref="CommunicationException"> when an exception occurred communicating with the Ingenico ePayments platform</exception>
        /// <exception cref="ResponseException">when an error response was received from the Ingenico ePayments platform</exception>
        /// <exception cref="ApiException">when an error response was received from the Ingenico ePayments platform which contained a list of errors</exception>
        public async Task <T> Delete <T>(string relativePath, IEnumerable <IRequestHeader> requestHeaders, AbstractParamRequest requestParameters,
                                         CallContext context)
        {
            IConnection connection = _session.Connection;
            IEnumerable <RequestParam> requestParameterList = requestParameters?.ToRequestParameters();
            Uri uri = ToAbsoluteURI(relativePath, requestParameterList);

            requestHeaders = requestHeaders ?? new List <IRequestHeader>();
            requestHeaders = AddGenericHeaders(HttpMethod.Delete, uri, requestHeaders, context);
            Response response = await connection.Delete(uri, requestHeaders);

            return(ProcessResponse <T>(response, relativePath, context));
        }
コード例 #6
0
        /// <summary>
        /// Corresponds to the HTTP PUT method.
        /// </summary>
        /// <param name="relativePath">The path to call, relative to the base URI.</param>
        /// <param name="requestHeaders">An optional list of request headers.</param>
        /// <param name="requestParameters">The optional set of request parameters.</param>
        /// <param name="requestBody">The optional request body to send.</param>
        /// <param name="context">The optional call context to use</param>
        /// <typeparam name="T">Type of the response.</typeparam>
        /// <exception cref="CommunicationException"> when an exception occurred communicating with the Ingenico ePayments platform</exception>
        /// <exception cref="ResponseException">when an error response was received from the Ingenico ePayments platform</exception>
        /// <exception cref="ApiException">when an error response was received from the Ingenico ePayments platform which contained a list of errors</exception>
        public async Task <T> Put <T>(string relativePath, IEnumerable <IRequestHeader> requestHeaders, AbstractParamRequest requestParameters,
                                      object requestBody, CallContext context)
        {
            IConnection connection = _session.Connection;
            IEnumerable <RequestParam> requestParameterList = requestParameters?.ToRequestParameters();
            Uri uri = ToAbsoluteURI(relativePath, requestParameterList);

            requestHeaders = requestHeaders ?? new List <IRequestHeader>();

            string requestJson = null;
            IList <IRequestHeader> requestHeaderList = requestHeaders.ToList();

            if (requestBody != null)
            {
                requestHeaderList.Add(new EntityHeader("Content-Type", "application/json"));
                requestJson = _marshaller.Marshal(requestBody);
            }

            requestHeaders = AddGenericHeaders(HttpMethod.Put, uri, requestHeaderList, context);
            Response response = await connection.Put(uri, requestHeaders, requestJson);

            return(ProcessResponse <T>(response, relativePath, context));
        }