Giter Club home page Giter Club logo

rtphplib's People

Contributors

christianchristensen avatar dalefrancum avatar dersam avatar emteedee avatar leusev avatar parisliakos avatar petski avatar timhci avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rtphplib's Issues

Add self-contained HTTP wrapper

Applications on shared hosting may not have access to pecl_http- a curl wrapper or another HTTP class should be integrated with the library to accommodate these situations.

Testing

Set up automated test suites and CI service.

Rework request building

Making an api request requires that the user look up all possible field names, and has no validation.

An api request should do the following:

  • Be aware of required fields, and error out if request is submitted without some required fields.
  • Across functions, the return values should be normalized.
  • Errors should be handled gracefully, and it should be easy to retrieve the error message returned by RT.

Problem using

Hello,

RT version : 4.0.4

Just discovered RTPHPLIB I am having some problem using this lib.
I tried using example.php(doTicketReply and getTicketProperties) but none is working.
Url, user and pass is OK.
Even if a put a wrong password, I get only a blank page.
Is there a specific config to do or requirements in RT for RTPHPLib to work?
I can't find any usage information on google.

curl is installed on the server hosting RTPHPLib but RTPHPLIB is not installed on the same server as RT.

Fix mutiline from fields and parse format

Hi, thank you for your great LIB, in my case I have some fields with multiline and your actual code doesn't work with them. So i modified your code to return all needed lines. And we can use this function with search format.

I hope that can help someone else :)

    private function parseResponseBody(array $response, $delimiter = ':')
    {
        $responseArray = array();
        $lastkey = null;

        foreach ($response as $line) {
            //RT will always preface a multiline with the length of the last key + length of $delimiter + one space)
            if(! is_null($lastkey) && preg_match('/^\s{' . ( strlen($lastkey) + strlen($delimiter) + 1 ) . '}(.*)$/', $line, $matches)) {
                $responseArray[$lastkey] .= "\n" . $matches[1];
            }
            elseif(! is_null($lastkey) && strlen($line) == 0) {
                $lastkey = null;
            }
            elseif(preg_match('/^#/', $line, $matches)) {
                $responseArray[$line] = '';
            }
            elseif(preg_match('~^([a-zA-Z0-9]+|CF\.{[^}]*})' . $delimiter . '\s+(.*)~', $line, $matches)) {
                $responseArray[$lastkey = $matches[1]] = $matches[2];
            }
            elseif ((bool) $line) {
                if (preg_match('/\s{4}/i', $line))
                    $line = preg_replace('/\s{4}/i', '', $line);

                $responseArray[$lastkey] .= PHP_EOL . $line;
            }
            elseif(is_null($lastkey) && preg_match('/\t/', $line)) {
                foreach ($response as $line) {
                    if (preg_match('/\t/', $line)) {
                        if (is_null($lastkey)) {
                            $lastkey ++;
                            $fields = explode("\t", $line);
                        }
                        elseif (! is_null($lastkey)) {
                            $result = explode("\t", $line);
                                foreach($fields as $key => $val) {
                                    $combined[$val] = $result[$key];
                                }
                            $responseArray[] = $combined;
                        }
                    }
                }
            }
        }

        return $responseArray;
    }

No display of an attachment image

Hi,

I'm trying to attach an image in comment/reply using the method doTicketComment for example and in the body of the ticket there is this message :

Message body is not shown because sender requested not to inline it

I understand that it is necessary to add the following option to CURLFIle Content-Disposition: attachment.

Has anyone ever had the same problem ? Otherwise could you help me please ?

Tests break on PHP7

This is probably due to phpunit updates. Might be as simple as changing the phpunit version.

No notification on non-session auth failure

If the service fails to authenticate when not using a session cookie, there is no AuthenticationException thrown, as there is with the session cookie login. We should detect this failure and throw the necessary exception.

getTicketProperties() fails after editTicket()

calling $rt->getTicketProperties($int) after $rt->editTicket($int, $array) will always response with "Ticket updated."
The reason is that $this->postFields is still filled with data from $rt->editTicket($int, $array). Every method that doesn't need to submit 'content' should call $this->setPostFields('') with an empty string to clear $this->postFields.

Issue in Multilne customfield

issue with the multi-line custom field getting wrong values
used getTicketProperties to get details

$response = $rt->getTicketProperties(31);

Actual Result :
[CF.{Location}] => sdsfs fsd fsdf s
[ f sfs sdf fsd sdf ] =>
[ sdf sdf fsdf sdfsdfs] =>
[ fsdfsd fsdfsd fsfsd fsdf] =>
[ sd fsdf sfsdf s] =>

Expected result
CF.{Location}] => sdsfs fsd fsdf s
f sfs sdf fsd sdf
sdf sdf fsdf sdfsdfs
fsdfsd fsdfsd fsfsd fsdf
sd fsdf sfsdf s

Response body parsing

Currently, the response body is returned as is. The library should provide a way to parse this into an easily manageable array structure.

query search result - array count mismatch

Hi,

it seems that the $responseArray returned by the $rt->search function has one "empty" item to much in it. My guess is that there is no longer a prefaced multiline with a single space as commented in the parseResponse function?

2015-10-02 19_47_21-info-center

SSL support

After line 364 for file RequestTracker.php you add the following 2 lines to make SSL work

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

Drop support for PHP 5.3

5.3 is EOL and no longer supported, and we would like to use CurlObjects to manage attachment files, which is only available in 5.5+.

Version 2 will drop support for PHP 5.3 to allow use of this directly in the library.

See #44

getAttachment() not binary-safe

getAttachment() has a Content-key. Unfortunately, the content of the corresponding value is crippled somewhere within RTPHPLib's code.

My tickets may contain an image. If getAttachment() is used, the content of $response["Content"] can't be displayed by any image viewer. Probably because RTPHPLib isn't binary-safe somewhere in it's logic.

As a work-around, I now use getAttachmentContent(), which does work as needed.

Improve response parsing

parseArray and parseResponse are kind of hacked together. We can improve this parsing:

  • Define a default parse function
  • The default can be overridden, depending on the request. This will allow for smarter parsing where necessary, based on the call type.

Better attachment handling

Provide a way to specify either attachment content directly, or to point to a file. Once created, the attachment reference should be stored in the current request and serialized at the point of dispatch.

Adding additional parameters to search function in RTPHPLib

Hello,
By the user interface of RT it is possible to add params for pagintation with:
&Page=1
&Rows=20
&RowsPerPage=20
but it looks like the search function in RTPHPLib doesn't provide a way for you to specify additional parameters. Do you know if is possible to do that?

Thanks a lot in advance

Sending multiline text in comment

Iโ€™m trying to send a comment in multi-lines to make it easier to read but it doesn't interpret the carriage return code \n
we tried with \r , \r\n and urlencode but none work

example text
"this is a test\nthis will not show or will crash"

ok not an issue, sorry for the post. Foud out that i need to leave a space after a carriage return to make it work.

add "fields" parameter to search function

I'm interested in specifying fields to return from, e.g., a ticket search (not just ticket id/title). I think it could be done pretty easily by just adding a parameter to the search function. I notice that there's already an open issue about that but it seems specifically to be about pagination, which might be more complicated. Thanks!

Support cookie authentication

Having to specify username & password all the time is bad if you want to use rt's users and not have a global username/password for every request.

Probably needs the v2.0 tag

Multiline replies only send first line

Calling $rt->doTicketReply($id, $content) with a multiline Text it will only send the first line. The replace that adds the space after linebreak is missing in that method.

Wiki is no longer up

Hey,

I just wanted to let you know that the wiki is no longer up. Any ideas when it will be?

getTicketHistory long format issue

At line 250, in your getTicketHistory method, you have the following:

$url = $this->url."ticket/$ticketId/history?format=1";

This will actually return the short history for the ticket, as the format is not recognized. It should be:

$url = $this->url."ticket/$ticketId/history?format=l";

Wrong operators in search method

Hi,

thanks for this great class, saved me a lot of work.

Search method contains assignment operators in stead of comparison operators.

if($format='s'){
$responseArray = static::parseResponse($response);
}
else if($format='i'){
return $response['body'];
}
else if($format='l'){
return $response['body'];
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.