CurrencyCloud/currencycloud-python

Potential issue with on_behalf_of parameter in retrieve requests

Closed this issue · 2 comments

Daniel Samuels wrote:

I've gone through and updated the majority of our application code to use on_behalf_of. One thing I have noticed however is that none of the retrieve endpoints allow for it to be passed through, even though it's listed as an optional parameter in the options, and does work when using bare HTTP requests. Is this a bug in the library, or does it not need to be passed for those endpoints?

I've tried to replicate the issue with the following code:

contact = currencycloud.Contact.retrieve('84cc1c8c-073c-4119-a233-3e79c7a2f0d9')

params = {
  'buy_currency': 'GBP',
  'sell_currency': 'USD',
  'fixed_side': 'buy',
  'amount': '1000',
  'reason': 'On behalf of test',
  'term_agreement': 'true'
}

with currencycloud.on_behalf_of(contact.id):
  conversion = currencycloud.Conversion.create(**params)

with currencycloud.on_behalf_of(contact.id):
  retrieved_conversion = currencycloud.Conversion.retrieve(conversion.id)

print "Retrieved conversion creator id: " + retrieved_conversion.creator_contact_id

The output of which is:

Retrieved conversion creator id: 84cc1c8c-073c-4119-a233-3e79c7a2f0d9

Daniel, is it possible to provide some example code with the issue that you see?

The test code I am using is below, note that I'm passing on_behalf_of through as a kwarg, not using currencycloud.on_behalf_of as a decorator. This is due to the fact that I'm using it as a kwarg everywhere else and would like my application to be consistent.

import currencycloud

response = currencycloud.Contact.find(
    login_id='danielpersonal@onespacemedia.com',
    status='enabled',
)

beneficiary_id = currencycloud.Beneficiary.find(
    on_behalf_of=response[0].id,
)[0].id

print dict(currencycloud.Beneficiary.retrieve(
    beneficiary_id,
    on_behalf_of=response[0].id,
))

Resolved in v1.0.0