CyberSource / CyberSource/cybersource-rest-samples-python

__dict__ vs to_dict()

Open
#33 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
29
Forks
34
PR merge metrics
No merged PRs in 30d

Description

Hey, this might be a strange thing to open an issue for, but I'm using the SDK to transition from Authorize.net AIM to CyberSource, and I noticed that all the examples use things like:

request.payment_information = payment_info.__dict__
# etc
message_body = json.dumps(request.__dict__)

instead of:

request.payment_information = payment_info
# etc
message_body = json.dumps(request.do_dict())

...even though the SDK provides to_dict() for a whole lot of things, so it looks like it was designed for that (and it avoids including unwanted attributes by accident). It looks like both ways produce the same output and work on the process_payment.py sample.

Is there a reason to prefer __dict__ each time over a single to_dict() at the end?

Thanks

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Begin with the process_payment.py sample and the SDK objects exposing to_dict(); compare the two serialization paths described in the issue. Done would require a maintainer-confirmed recommendation and, if examples should change, a clearly identified documentation or sample update; the issue names no target file or test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.