ShopifySharp icon indicating copy to clipboard operation
ShopifySharp copied to clipboard

HttpResponseMessage Response in RequestResult marked as Obsolete

Open Pedro-Monteiro-1211076 opened this issue 1 year ago • 2 comments

I am logging HTTP requests and responses by creating an IRequestExecutionPolicy. Below is a simplified version of my class without the logging:

public class LoggingExecutionPolicy<T> : IRequestExecutionPolicy
{
    public async Task<RequestResult<T>> Run<T>(CloneableRequestMessage requestMessage, ExecuteRequestAsync<T> executeRequestAsync, 
        CancellationToken cancellationToken, int? graphqlQueryCost = null)
    {

        // Send request
        var result = await executeRequestAsync(requestMessage);

        return result;
    }
}

I have no problem logging the request. To log the response I use the result variable which is of the type RequestResult. This class has the attribute HttpResponseMessage Response which is perfect to log the response (I just need the status code). However, it is marked as Obsolete and I am wondering what should I use instead to obtain the status code.

Pedro-Monteiro-1211076 avatar Apr 29 '24 09:04 Pedro-Monteiro-1211076

Hey @Pedro-Monteiro-1211076, sorry it took so long to respond, I meant to get back to you right away. Thanks for pointing this out! I can see how it'd be useful to have the status code here, I'll make sure it gets added to the RequestResult class in my next release.

nozzlegear avatar May 10 '24 03:05 nozzlegear

Hello @nozzlegear, no worries. Thanks for considering my suggestion and implementing it! Do you have an estimate of when you will publish the next release? Keep up the good work.

Pedro-Monteiro-1211076 avatar May 10 '24 09:05 Pedro-Monteiro-1211076

Planning to release it today (Monday)! I've got a new request execution policy I'm cooking up that I'd like to release as well, just need to finish up the tests for that and then I'll push out a release for both of them.

nozzlegear avatar May 13 '24 06:05 nozzlegear

@Pedro-Monteiro-1211076 A couple days late, but this is now published in 6.16.0 on Nuget. You should be able to access the status code with result.HttpStatusCode once you update to the latest version. Let me know if you have any trouble using it!

nozzlegear avatar May 15 '24 05:05 nozzlegear

Hey @nozzlegear, I have updated the Nuget and everything seems to be working fine. Thank you very much. I have just realized that the content of the response (which is obselete) would also be useful, do you think that in a future release that could be added?

Pedro-Monteiro-1211076 avatar May 15 '24 13:05 Pedro-Monteiro-1211076