tallus / python-civicrm Goto Github PK
View Code? Open in Web Editor NEWModule for interacting with civicrm api v3
License: GNU General Public License v2.0
Module for interacting with civicrm api v3
License: GNU General Public License v2.0
I found the following issue: I'm using the code against a demo installation of CiviCRM on a VM and the virtual machine does not have SSL activated, so I was using use_ssl=False
.
today I started testing against a real server which has SSL but I forgot to change the value of the parameter; this lead to 2 issues:
limit
and offset
) just did not work at allCiviCRM API documentation only talks about an URL, I think we should provide an URL and let the user decide with that parameter if she wants to use HTTP or HTTPS.
why did you added the use_ssl
option on the first place? may I missing something?
if you explain me how you run tests, I can set up a Travis CI configuration so the code is tested on every commit.
you will also need to enable the Travis CI webhook on the repo configuration.
Parts of the CiviCRM API require key-value pairs where the value is an array -- possibly even an array of arrays. Such values are not transferred using the normal HTTP parameters, but can be if they are json encoded.
Sadly, the json key is explicitly excluded from the values passed to the server.
The simple option is to remove the 'json' entry in the notparams array in the function _construct_post_data(). This way, the caller can construct a JSON array containing the necessary values, and pass them in:
params = {
u'name': template.name,
u'subject': template.subject,
u'created_id': template.creator_id,
u'api.mailing_job.create': 0
}
# parameters that are json-encoded into the request.
config = {
u'from_name': template.from_name,
u'url_tracking': u'1',
u'groups' = {u'include': groupids,
u'exclude': []}
u'scheduled_date' = u'now'
}
params[u'json'] = json.dumps(config)
results = civicrm.create(u'Mailing', **params)
However, as the code above suggests, it is still necessary to render some items within a non-json array, as otherwise checks for required parameters (created_id, subject, and name in this case) fail.
Therefore I suggest that the correct answer is to modify the civicrm class to auto-wrap values into the json -- perhaps by simply checking for is-array(value), or by maintaining a list of required keys that cannot be json'd -- and build in the use of the json key.
Whether the above is needed for URL parameters I don't know. I am tempted by the answer -- use json for everything that it can be -- as values will not be unfortunately munged.
Reference 'example.org/sites/all/modules/civi/extern/rest.php' and the standard path and include something about generating/storing API keys.
Hi, it would be nice if this could be installed with pip install pythoncivicrm
. I've tried to use a workaround (pip install git+https://github.com/tallus/python-civicrm) but this doesn't work (you can try it out yourself, it's not possible to import any symbols from pythoncivicrm after doing this).
to test my code, I'm trying to mock a CiviCRM server using httmock.
I'm copying the return data from a testing CiviCRM server and I found an issue while using get
GroupContact
: the result of the call is a dictionary of dictionaries instead of a list of dictionaries:
(Pdb) groups
{u'1': {u'group_id': u'2', u'title': u'Newsletter Subscribers', u'visibility': u'Public Pages', u'in_method': u'Email', u'is_hidden': u'0', u'in_date': u'2013-02-25 09:10:15', u'id': u'1'}, u'76': {u'group_id': u'4', u'title': u'Advisory Board', u'visibility': u'Public Pages', u'in_method': u'Email', u'is_hidden': u'0', u'in_date': u'2013-07-14 08:48:57', u'id': u'76'}}
the source code is here: https://github.com/collective/collective.civicrm/blob/master/src/collective/civicrm/browser/contact.py#L55
I was checking your code and I saw you're testing against a live server and I was wondering if you are interested in implementing some mocking to be able to test the code better.
what I have done until now is here: collective/collective.civicrm@1188b96
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.