Package: moco-wrapper
moco-wrapperThis is a client implementation of the moco api written in python3.InstallationFrom pypiThe moco-wrapper package is available viapip.$pip3installmoco-wrapperFrom SourceIf dont want to use pip you can clone this repository and install it from the source.$gitclonehttps://github.com/sommalia/moco-wrappermoco-wrapper$cd./moco-wrapper$pip3install-rrequirements_dev.txt$makeinstallQuickstartIf you already have credentials or an api key you can instantiate your moco-wrapper object like so:importmoco_wrappermoco=moco_wrapper.Moco(auth={"api_key":"[MY API KEY]","domain":"example"# domain of the moco webapp is example.mocoapp.com})With the moco wrapper object you can now interact with moco.# load a list of usersusers=moco.User.getlist()# load the second page of our list of users# requests with lists are paginated# default limit is 100 items per requestusers_page_two=moco.User.getlist(page=2)# create a projectleader=moco.User.getlist()[0]customer=moco.Company.getlist(type="customer").getlist()[0]project=moco.Project.create(name="my new project",currency="EUR",leader_id=leader.id,customer_id=customer.id,finish_date=date(2020,1,1))# update a contactmoco.Contact.update(contact_id=55123,lastname="doe")# add a task to a projecttask=moco.Task.create(project_id=project.id,name="My new task")# create a new customernew_customer=moco.Company.create(name="my new customer company",company_type=moco_wrapper.models.company.CompanyType.CUSTOMER)For an overview about all the things that can and cannot be done seeThe Moco Instance.TestsThere are two types of tests in this repo.unit-tests with no side effects
andintegration-tests that require an actual moco instance (if you want to recreate the cached responses).UnitThese tests check whether all methods can be called correctly, use the
right HTTP method, have the right headers and format everything correctly for the API.
These tests have no side effects and can be run via pytest:$python3-mpytesttests/unitIntegrationThe second group of tests are theintegrationtests.
These tests use the betamax package, send actual requests to a moco instance and save the response locally (see tests/integration/cassettes/).
These tests can also be run via pytest:$python3-mpytesttests/integrationRecreating the tests resultsIf you want to recreate these tests make sure you have the following setup:A working, clean moco instance (eg. example.mocoapp.com)An api keyTime to spareAfter that you have to export the following variables$exportmocotest_apikey=[MYAPIKEY]$exportmocotest_domain=example$exportmocotest_delay=1# enable delay between testsThemocotest_delayvariable will make sure that the api, does not rate limit our test-run
by waiting 5 seconds between the execution of each single test.Caution:Make sure you run the integration tests (if you recreate the results) on a clean moco instance,
as some requests (delete. create and update requests) have side effects, that cannot be reversed easily.Now that everything is set up we delete the saved responses and re-run the tests.$rmtests/integration/cassettes/*.json$python3-mpytesttests/integrationDocumentationThe full documentation for the moco-wrapper is located athttps://moco-wrapper.readthedocs.io/.LicenseThis project is licensed under the GNU Public License - see theLICENSEfile for detailsCreditsThis package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.
This package tries to imitate the way that thepraw-package, for wrapping around the reddit api, was structuredHistory0.11.2 (2023-05-23)Deletion of companies0.11.1 (2022-04-05)Create deals with tagsGetlist of companies with terms0.11.0 (2021-11-05)Added support of project destructionAdded extended service period parameters to project expensesAdded creating project expenses with filesAdded seconds parameter to activity update for more detailed loggingAdded purchase draftsRenamed labels to tagsMoved file handling into its own helper class0.10.1 (2021-06-28)Add support for custom properties in contact, deal, offer and invoice0.10.0 (2021-04-07)ListResponses and PagedListResponses now behave like listsChanged how api routes are processedIn the old versions the objector has a map of all routes that are available and how the may back to objectsNow each model declares the routes by itself and which object will be returnedIn this release the old map, and the old methods are still present, they will be removed in a future releaseChanged the timesheet endpoint of the invoice model to timesheet_pdf for clearer distinction between timesheet_pdf and the new method timesheet_activitiesRenamed HourlyRates model to AccountHourlyRatesAdded verify method to Session modelImplemented AccountInternalHourlyRates modelAdded getall method to ProjectPaymentSchedule modelAdded more optional parameters to other methods0.9.0 (2020-12-24)Reworked response classesSplit ListingResponse into 2 separate classesListResponse for unpaged response dataPageListResponse for paginated response dataRenamed JsonResponse to ObjectResponseImplemented taggings endpointAddedclickupremote serviceCleaned up tests0.8.1 (2020-11-17)Removed Project from Schedules (only used for Absences)Cleanup testsAdded deal parameter to project create and updateImplemented invoice send_email endpointImplemented hourly rates endpoint0.8.0 (2020-06-28)New ReadmeAdd return types to documentation (for default configuration of moco instance only)Implement Purchase modelAllow overwrite of http headers from model classesFix some typos in method names (offer item generator) and parameter (user holidays)0.7.2 (2020-06-05)Implement update_status endpoint of offer model0.7.1 (2020-05-30)Create new Releases with bumpversionImplemented tags parameter in invoice creation0.7.0 (2020-05-27)Implemented Planning EntriesAdd credit/debit number to CompanyAdd footer to CompanyAdd deal property to Project objector model0.6.3 (2020-04-29)CleanupFixed example code in documentationFixed various typosImplemented contact lookup by phone number and term0.6.2 (2020-03-24)Query strings conversion into lower case0.6.1 (2020-03-18)Implement support for days parameter in User holidaysImplement Purchase Categories0.6.0 (2020-03-07)Implemented Paging of Listing ModelsImplemented the creation of fixed price projectsImplement Project Payment Schedules for fixed price projectsMore Documentation and even more code cleanup0.5.0 (2020-02-29)Implement authentication via email and password (note that the class constructor also changed, if you do not want that continue to ues the previus version (0.4.1))Create readthedocs documentation (seehttps://moco-wrapper.readthedocs.io)Error Responses are now converted into actual Exceptions that are raisedCode Cleanup0.4.1 (2020-02-24)Implemented impersonationFixed makefile (make test does work now if you have the required packages installed)Created documentation see (https://moco-wrapper.readthedocs.io/en/latest/)Added named arguments requestor and objector to moco_instance constructor (Setting the requestor via moco.http is no longer possible, user moco.requestor)Removed cli component0.4.0 (2020-02-19)Finished reworking all the integration testsPrefixed Employment, Holiday and Presense with “User” for clarificationMoved duplicated methods id_generator and create_random date into base classImplented additional requestor that only tries once to request the api endpoint (no retrying)Main moco object moved to namespace moco_wrapper.mocoChanged author email0.3.0 (2020-02-17)Create github workflow to automaticly deploy to PyPIImplement an objector to control how the json responses get converted back into python objects (some endpoints return data that contain reserved python keywords, this was implemented to circumvent that)More Tests and more type hintingWrite the history of the last versionsChange the order of things in this history fileImplement offer creation0.2.3 (2020-02-09)Implement FileResponses for downloading pdf files from apiImplement invoice class api changesMore tests0.2.2 (2020-01-12)Start implementing type hintingSwitch to support python3 onlyRemove company delete method, as it is not support by the apiMore Tests0.2.1 (2020-01-10)More tests0.1.0 (2019-09-04)First release on PyPI.