Skip to content

Commit

Permalink
Add MobileCommons Connector (#896)
Browse files Browse the repository at this point in the history
* mobilecommons class

* Update __init__.py

* get broadcasts

* fix get broadcast request

* Add mc_get_request method

* Add annotation

* Incorporate Daniel's suggestions and finish up get_broadcasts

* A few more methods

Need to figure out page_count issue

* small fix

* Remove page_count, use page record num instead

* Add in page_count again

Not all get responses include num param, but do include page_count. wft

* Fix logging numbers

* Add create_profile

* Fix error message for post request

* Start tests

* Add some tests

* Continue testing

* Update test_mobilecommons.py

* functionalize status_code check

* break out parse_get_request function

* fix test data

* fix documentation typo

* Add several tests

* Update mobilecommons.py

* Fix limit and pagination logic

* debug unit testing

* better commenting and logic

* Documentation

* Add MC to init file

* Revert "Merge branch 'main' into cormac-mobilecommons-connector"

This reverts commit cad250f, reversing
changes made to 493e117.

* Revert "Add MC to init file"

This reverts commit 493e117.

* Revert "Revert "Add MC to init file""

This reverts commit 8f87ec2.

* Revert "Revert "Merge branch 'main' into cormac-mobilecommons-connector""

This reverts commit 8190052.

* Fix init destruction

* fix init yet again

* Update testing docs with underscores

* Lint

* Lint tests

* break up long responses

* Fix more linting issues

* Hopefully last linting issue

* DGJKSNCHIVBN

* Documentation fixes

* Remove note to self

* date format

* remove random notes

* Update test_mobilecommons.py

---------

Co-authored-by: sharinetmc <[email protected]>
  • Loading branch information
cmdelrio and sharinetmc authored Oct 25, 2023
1 parent 2173478 commit 5b627fb
Show file tree
Hide file tree
Showing 8 changed files with 860 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ Indices and tables
google
hustle
mailchimp
mobilecommons
mobilize_america
nation_builder
newmode
Expand Down
49 changes: 49 additions & 0 deletions docs/mobilecommons.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
MobileCommons
==========

********
Overview
********

`MobileCommons <https://secure.mcommons.com/>`_ is a broadcast text messaging tool that helps orgranizations
mobilize supporters and fundraise by building opt-ed in audiences. You can read more about the product
`here <https://uplandsoftware.com/mobile-messaging/>`_.

***********
Quick Start
***********

To instantiate a class you must pass the username and password of a MobileCommons account as an argument
or store the username and password into environmental variables called ``MOBILECOMMONS_USERNAME`` and
``MOBILECOMMONS_PASSWORD``, respectively. If you MobileCommons account has access to various MobileCommons
companies (i.e. organizations), you'll need to specify which MobileCommons company you'd like to interact
with by specifying the Company ID in the ``company_id`` parameter. To find the Company ID, navigate to the
`Company and Users page <https://secure.mcommons.com/companies/>`_.

.. code-block:: python
from parsons import MobileCommons
# Pass credentials via environmental variables for account has access to only one MobileCommons company
mc = MobileCommons()
# Pass credentials via environmental variables for account has access to multiple MobileCommons companies
mc = MobileCommons(company_id='EXAMPLE78363BOCA483954419EB70986A68888')
# Pass credentials via argument for account has access to only one MobileCommons company
mc = MobileCommons(username='[email protected]', password='badpassword123')
Then you can call various endpoints:

.. code-block:: python
# Return all MobileCommons subscribers in a table
subscribers = get_campaign_subscribers(campaign_id=1234567)
# Create a new profile, return profile_id
new_profile=create_profile(phone=3073991987, first_name='Jane', last_name='Fonda')
***
API
***
.. autoclass :: parsons.MobileCommons
:inherited-members:
1 change: 1 addition & 0 deletions parsons/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
("parsons.google.google_sheets", "GoogleSheets"),
("parsons.hustle.hustle", "Hustle"),
("parsons.mailchimp.mailchimp", "Mailchimp"),
("parsons.mobilecommons.mobilecommons", "MobileCommons"),
("parsons.mobilize_america.ma", "MobilizeAmerica"),
("parsons.nation_builder.nation_builder", "NationBuilder"),
("parsons.newmode.newmode", "Newmode"),
Expand Down
3 changes: 3 additions & 0 deletions parsons/mobilecommons/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from parsons.mobilecommons.mobilecommons import MobileCommons

__all__ = ["MobileCommons"]
Loading

0 comments on commit 5b627fb

Please sign in to comment.