Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update: Add as_json param to Salesforce.restful #645

Open
wants to merge 11 commits into
base: release/v1.12.6
Choose a base branch
from

Conversation

michotross257
Copy link

@michotross257 michotross257 commented Apr 21, 2023

When requesting an event log file using Salesforce.restful (which returns CSV data), you receive a JSONDecodeError. By including the suggested param, you can bypass JSON deserialization.

Example workaround that would be handled by new restful param:

import os

from simple_salesforce import Salesforce

LOG_FILE_PATH = 'sobjects/EventLogFile/xxxxxxxxxxxxxxxxxx/LogFile'

salesforce_conn = Salesforce(
    username=os.environ['SALESFORCE_USERNAME'],
    password=os.environ['SALESFORCE_PASSWORD'],
    security_token=os.environ['SALESFORCE_SECURITY_TOKEN'],
    instance_url=os.environ['SALESFORCE_INSTANCE_URL']
)

# raises JSONDecodeError
# result = salesforce_conn.restful(LOG_FILE_PATH)

# returns CSV data without any error
result = salesforce_conn._call_salesforce(
    method='GET',
    url=salesforce_conn.base_url + LOG_FILE_PATH,
    name=LOG_FILE_PATH
)

ericl-billgo and others added 7 commits April 20, 2023 11:04
* Bug/pyjwt dependency (simple-salesforce#610)

* Update setup.py

Update pyjwt dependency

* Update setup.py

include cryptography for requirement for pyjwt

* Update setup.py

include pyjwt[crypto] in install requirements

* Update setup.py

remove [crypto] from pyjwt[crypto] in install_requires as causes travis-ci failure to build

* remove extra leading space

---------

Co-authored-by: JonWobken <49450080+jon-wobken@users.noreply.github.com>
…s_hook (simple-salesforce#634)

* Bug/pyjwt dependency (simple-salesforce#610)

* Update setup.py

Update pyjwt dependency

* Update setup.py

include cryptography for requirement for pyjwt

* Update setup.py

include pyjwt[crypto] in install requirements

* Update setup.py

remove [crypto] from pyjwt[crypto] in install_requires as causes travis-ci failure to build

* Updated __getattr__ function to create SFType object with object_pairs_hook as input

Right now let us say that the user creates a SFType object using __getattr__ function which is present in the class SalesForce. If the SalesForce object is initiated using object_pairs_hook being dict or print. In that case the user would want the response from SFType to be same as that object as well. So I have added object_pairs_hook in the SFType object which is being called in the __getattr__ function of the SalesForce Class

* Updated __getattr__ function to create SFType object with object_pairs_hook

Right now let us say that the user creates a SFType object using getattr function which is present in the class SalesForce. If the SalesForce object is initiated using object_pairs_hook being dict or print. In that case the user would want the response from SFType to be same as that object as well. So I have added object_pairs_hook in the SFType object which is being called in the getattr function of the SalesForce Class

* removed whitespaces

* pylint

---------

Co-authored-by: JonWobken <49450080+jon-wobken@users.noreply.github.com>
* Bug/pyjwt dependency (simple-salesforce#610)

* Update setup.py

Update pyjwt dependency

* Update setup.py

include cryptography for requirement for pyjwt

* Update setup.py

include pyjwt[crypto] in install requirements

* Update setup.py

remove [crypto] from pyjwt[crypto] in install_requires as causes travis-ci failure to build

* Fix indent in setup.py

---------

Co-authored-by: JonWobken <49450080+jon-wobken@users.noreply.github.com>
* Bug/pyjwt dependency (simple-salesforce#610)

* Update setup.py

Update pyjwt dependency

* Update setup.py

include cryptography for requirement for pyjwt

* Update setup.py

include pyjwt[crypto] in install requirements

* Update setup.py

remove [crypto] from pyjwt[crypto] in install_requires as causes travis-ci failure to build

* fix: use unescaped username for JWT claim

JWT Bearer Flow needs JWT claim sub containg unescaped username
Connected App Login has been fixed by simple-salesforce#604

---------

Co-authored-by: JonWobken <49450080+jon-wobken@users.noreply.github.com>
@michotross257 michotross257 changed the title Update: Added as_json param to Salesforce.restful Update: Add as_json param to Salesforce.restful Apr 21, 2023
@jon-wobken jon-wobken changed the base branch from master to release/v1.12.4 April 25, 2023 21:02
@michotross257
Copy link
Author

Hi @jon-wobken - can you review these changes please? Thanks

@jon-wobken
Copy link
Collaborator

@michotross257 - going to try to get all the pending pulls reviewed by Friday/Saturday and release a new version

@michotross257
Copy link
Author

Hi @jon-wobken - have you have a chance to review this PR?

@jon-wobken jon-wobken changed the base branch from release/v1.12.4 to release/v1.12.6 October 24, 2023 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants