def createJob(self, content, rtype=httpFormats.formats.JSON): rtype = httpFormats.formats(rtype) response = self.createJobRaw(content, rtype) if response.success() is True: response.__rawContent = response.content response.content = self._parseOutput(rtype, response.content) return response
def orderJobsInCart(self, rtype=httpFormats.formats.JSON): rtype = httpFormats.formats(rtype) response = self.orderJobsInCartRaw(rtype) if response.success() is True: response.__rawContent = response.content response.content = self._parseOutput(rtype, response.content) return response
def updateJob(self, token, jobObject, rtype=httpFormats.formats.JSON): rtype = httpFormats.formats(rtype) response = self.updateJobRaw(token, jobObject, rtype) if response.success() is True: response.__rawContent = response.content response.content = self._parseOutput(rtype, response.content) return response
def getDownloadFile(self, token, rtype=httpFormats.formats.JSON): rtype = httpFormats.formats(rtype) response = self.getDownloadFileRaw(token, rtype) if response.success() is True: response.__rawContent = response.content response.content = self._parseOutput(rtype, response.content) return response
def createJobRaw(self, content, rtype=httpFormats.formats.JSON): if self.connected is False: raise TDError( 'Session error: session not connected. Call function "TrimbleDataSession.connect()" before any API call.' ) if isinstance(content, TrimbleDataJob) is True: rContent = content.getContent() elif isinstance(content, dict) is True: rContent = content else: raise TDError("Type error: the job object is not a job object or a dictionary object") rtype = httpFormats.formats(rtype) path = "jobs." + str(rtype) if rtype == "json": request = json.dumps(rContent, encoding="utf-8") else: if isinstance(content, TrimbleDataJob) is True: request = content.toXML() else: tJob = TrimbleDataJob() request = tJob.toXML(rContent) return self._session.post(path, request)
def getJobs(self, rtype=httpFormats.formats.JSON, *filters): rtype = httpFormats.formats(rtype) response = self.getJobsRaw(rtype, *filters) if response.success() is True: response.__rawContent = response.content response.content = self._parseOutput(rtype, response.content) return response
def getDownloadFileRaw(self, token, rtype=httpFormats.formats.JSON): if self.connected is False: raise TDError( 'Session error: session not connected. Call function "TrimbleDataSession.connect()" before any API call.' ) rtype = httpFormats.formats(rtype) path = "jobs/" + token + "/download." + str(rtype) return self._session.get(path)
def getJobsInCartRaw(self, rtype=httpFormats.formats.JSON): if self.connected is False: raise TDError( 'Session error: session not connected. Call function "TrimbleDataSession.connect()" before any API call.' ) rtype = httpFormats.formats(rtype) path = "jobs/show_cart." + str(rtype) return self._session.get(path)
def orderJobsInCartRaw(self, rtype=httpFormats.formats.JSON): if self.connected is False: raise TDError( 'Session error: session not connected. Call function "TrimbleDataSession.connect()" before any API call.' ) rtype = httpFormats.formats(rtype) path = "order/cart/process." + str(rtype) content = '{"order": {"payment_method_id": null}}' return self._session.post(path, content)
def getJobsRaw(self, rtype=httpFormats.formats.JSON, *filters): if self.connected is False: raise TDError( 'Session error: session not connected. Call function "TrimbleDataSession.connect()" before any API call.' ) rtype = httpFormats.formats(rtype) jFilter = None if len(filters) > 0: jFilter = [] for f in filters: jFilter.append(f) path = "jobs." + str(rtype) return self._session.get(path, queryStrings=jFilter)
def _parseOutput(self, rtype, output): if rtype is None: return output rtype = httpFormats.formats(rtype) if len(output.strip()) == 0: pOutput = output elif rtype == "xml" or rtype == "weo" or rtype == "kml": pOutput = output elif rtype == "json": pOutput = json.loads(output) else: pOutput = output return pOutput