#jamie-aitken_code

1 messages · Page 1 of 1 (latest)

twin pantherBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1395715371528355900

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

gusty island
#

With the changes to the Stripe client within the Go SDK, how can I access the LastResponse for each of the objects?
Could you please share a concrete example of this to better understand you ?

pulsar estuary
#

Sure, here's an example using Dispute's List

Prior to migrating to the new Client, we had code such as

p := &stripe.DisputeListParams{
    PaymentIntent: stripe.String(params.PaymentIntentID),
}
p.Context = ctx

iter := c.disputeClient.List(p)

disputeList, ok := iter.List().(*stripe.DisputeList)
if !ok {
    return nil, errFailedToCastToDisputeList
}

disputeListLastResponse, err := getDisputeListLastResponse(disputeList.LastResponse)
if err != nil {
    return nil, err
}
for iter.Next() {
  // Logic associated with a Dispute    
}

After migrating to this client, we have something like this

p := &stripe.DisputeListParams{
    PaymentIntent: stripe.String(params.PaymentIntentID),
}

for dispute, err := range c.disputeClient.List(ctx, p) {
    if err != nil {
        return nil, err
    }
        
    // This is nil
    lastResponse := dispute.LastResponse

        // Logic associated with a Dispute
}

The LastResponse on each Dispute within that List is nil which is problematic because we no longer have access to the DisputeList which we did prior to migrating to the new client. Is it expected that when using the new client, each Dispute should have a value for LastResponse?

gusty island
#

Ah I see what you mean, thanks for the additional context

#

Checking...

#

You need to update the line:
lastResponse := dispute.LastResponse
To
lastResponse := dispute

After the Seq2 is consumed, you should have the lastResponse object

#
lastResponse := &..{}

for dispute, err := range c.disputeClient.List(ctx, p) {
    if err != nil {
        return nil, err
    }
        
    // This is nil
    lastResponse := dispute

        // Logic associated with a Dispute
}
pulsar estuary
#

Could you elaborate on this example a little more please, to show how I'd get the RawJSON value associated with the Dispute's LastResponse?

gusty island
#

Ah wait, I though you want to get the latest item in the list

pulsar estuary
gusty island
#

For preview field, you should use the beta version of the GO SDK, is it the case for you ?

pulsar estuary
#

How would using a beta version help? We've never had to use betas in the past this value is 100% in the RawJSON value, we just need to be able to access it and follow the advice Stripe has given to access undocumented proerties

gusty island
#

IN order to use a preview feature, you need to use the corresponding preview field

#

Do you have the guide you are following for that preview field ?

#

I'm not able to find it internally ?

pulsar estuary
#

Unless something has changed, I'm not sure that's true. We are able to access this field using V79 (non-beta) by following the advice I've linked above.

I've attached a screenshot of the property we're interested in

gusty island
#

You code is trying to access the field LastResponse and not NetworkDetails.Visa... 🤔

pulsar estuary
#

Yes because LastResponse contains the RawJSON. The RawJSON contains NetworkDetails.Visa. The SDK takes the RawJSON and unmarshals it into a Go struct. However, because this field is not represented in the SDK, we have to follow the advice that I've linked above in order to access it

gusty island
#

Oké, that's why I suggested using the preview feature of the SDK, so that you can simply do dispute.NetworkDetails.Visa and not accessing the rawJson of the item

pulsar estuary
#

I don't think this has representation in any SDK release though, even the betas!

gusty island
#

Did you tried last beta ?

#

Note that where API resources are nested in other API resources, only LastResponse on the top-level resource is set.

#

The only option here, is to use the corresponding beta version of the SDK that exposes that field.

pulsar estuary
#

Can you explain the rationale why you think the last beta would fix my issue here?

gusty island
#

I just did a test, and it seems like the NetworkDetails isn't exposed in the latest beta (I don't even see it in the changelog yet)

pulsar estuary
#

This all seems like an oversight with the new client to be honest and the fact that we no longer have access to the List's LastResponse

#

I just did a test, and it seems like the NetworkDetails isn't exposed in the latest beta (I don't even see it in the changelog yet)
yeah, this isn't a new feature, we've been using it for months

gusty island
pulsar estuary
#

Yeah, can do! Would I be able to reference this thread in the issue?

gusty island
#

Yeah sure.

#

Please share it with me here, so that I can flag it internally too with the owning team

pulsar estuary
#

Thanks for your time mate, will do

gusty island
#

Np! Always happy to help!