Code Monkey home page Code Monkey logo

python-civicrm's People

Contributors

hvelarde avatar rivimey avatar tallus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

python-civicrm's Issues

why do we need the use_ssl parameter?

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:

  • the connection was being opened twice: one for HTTP and another for HTTPS, probably because of a redirection on the server
  • the results were not what I expected and some parameters (like limit and offset) just did not work at all

CiviCRM 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?

Running tests on CI

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.

Cannot make Civi requests requiring array parameters, e.g. Mailing "groups = array(include=array(idlist))"

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.

Improve documentation

Reference 'example.org/sites/all/modules/civi/extern/rest.php' and the standard path and include something about generating/storing API keys.

Make it pip installable

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).

Mock a CiviCRM server

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.