Пример #1
0
 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
Пример #2
0
 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
Пример #3
0
 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
Пример #4
0
 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
Пример #5
0
    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)
Пример #6
0
 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
Пример #7
0
 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)
Пример #8
0
 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)
Пример #9
0
 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)
Пример #10
0
 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)
Пример #11
0
 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