The Moco Instance¶
-
class
moco_wrapper.
Moco
(auth={}, objector=<moco_wrapper.util.objector.default.DefaultObjector object>, requestor=<moco_wrapper.util.requestor.default.DefaultRequestor object>, impersonate_user_id: int = None, **kwargs)¶ Main Moco class for handling authentication, object conversion, requesting ressources with the moco api
Parameters: - auth (dict) – Dictionary containing authentication information, see Authentication
- objector – objector object (see Objector, default:
moco_wrapper.util.objector.DefaultObjector
) - requestor – requestor object (see Requestor, default:
moco_wrapper.util.requestor.DefaultRequestor
) - impersonate_user_id (int) – user id the client should impersonate (default: None, see https://github.com/hundertzehn/mocoapp-api-docs#impersonation)
import moco_wrapper moco = moco_wrapper.Moco( auth = { "api_key": "<TOKEN>", "domain": "<DOMAIN>" } )
-
auth
= None¶ Authentication information
It either contains an api key and and domain
from moco_wrapper import Moco m = Moco( auth={"api_key": "here is my key", "domain": "testdomain"} )
Or it contains domain, email and password
from moco_wrapper import Moco m = Moco( auth={"domain": "testdomain", "email": "testemail@mycompany.com", "password": "test"} )
-
authenticate
()¶ Performs any action necessary to be authenticated against the moco api.
This method gets invoked automatically, on the very first request you send against the api.
-
clear_impersonation
()¶ Ends impersonation
See also
-
delete
(path, ep_params=None, params=None, data=None, **kwargs)¶ Helper function for DELETE requests
-
full_domain
¶ Returns the full url of the moco api
>> m = Moco(auth={"domain": "testabcd", ..}) >> print(m.full_domain) https://testabcd.mocoapp.com/api/v1
-
get
(path, ep_params=None, params=None, data=None, **kwargs)¶ Helper function for GET requests
-
headers
¶ Returns all http headers to be used by the assigned requestor
-
impersonate
(user_id: int)¶ Impersonates the user with the supplied user id
Parameters: user_id – user id to impersonate See also
clear_impersonation()
to end impersonation ofuser_id
-
patch
(path, ep_params=None, params=None, data=None, **kwargs)¶ Helper function for PATCH requests
-
post
(path, ep_params=None, params=None, data=None, **kwargs)¶ Helper function for POST requests
-
put
(path, ep_params=None, params=None, data=None, **kwargs)¶ Helper function for PUT requests
-
request
(method: str, path: str, params: dict = None, data: dict = None, bypass_auth: bool = False, **kwargs)¶ Requests the given resource with the assigned requestor
Parameters: - method – HTTP Method (eg. POST, GET, PUT, DELETE)
- path – path of the resource (e.g.
/projects
) - params – url parameters (e.g.
page=1
, query parameters) - data – dictionary with data (http body)
- bypass_auth – If authentication checks should be skipped (default False)
The request will be given to the currently assigned requestor (see Requestor). The response will then be given to the currently assigned objector (see Objector)
The possibly modified response will then be returned
-
session
¶ Get the http.session object of the current requestor (None if the requestor does not have a session)
- Account Fixed Costs
- Account Hourly Rate
- Account Internal Hourly Rate
- Activity
- Comment
- Company
- Contact
- Deal
- Deal Category
- Invoice
- Invoice Payment
- Offer
- Project
- Project Contract
- Project Expense
- Project Recurring Expense
- Project Payment Schedule
- Project Task
- Planning Entry
- Purchase
- PurchaseCategory
- Schedule
- Tagging
- Unit
- User
- User Employment
- User Holiday
- User Presence
- Session