Coder Social home page Coder Social logo

tessera's Introduction

Tessera

This gem is intended as JSON API wrapper for OTRS 6.

Documentation of this API with curl examples can be found here

Installation

Add this line to your application's Gemfile:

gem 'tessera'

And then execute:

$ bundle

Or install it yourself as:

$ gem install tessera

Usage

First of all you have to setup your creadentials like so:

Tessera.configure do |config|
  config.username = 'jon'
  config.password = 'SuperSecret'
  config.base_url = 'https://otrs.com/otrs/nph-genericinterface.pl/Webservice/rest/'
end

Now you also have to load yourself webservice yml file locate here Please do use one enclosed with this gem from github since name of the webservice is hardcoded for now, will appear in TODO section for further adjustments...

Gem provides you Tessera::Ticket class to use now with following methods:

FIND

You can find ticket by its ID or by array of IDS like so:

ticket = Tessera::Ticket.find(1)
tickets = Tessera::Ticket.find([1, 2, 3])

WHERE

You can search through tickets like so:

results = Tessera::Ticket.where(Title: 'Whic%')

for the list of all available options to search through you can see this page

Following where call you get the results object on which you can either choose if you want array of Tickets or you are just interested in count of them:

results.tickets

results.count

CREATE

You can create new ticket like so:

params = {
  ticket: {
    title: 'New ticket',
    queue: 2,
    state: 'new',
    priority: 3,
    customer_user: 'andrej',
    customer_id: 'aaaaa'
  },
  article: {
    from: '[email protected]',
    to: '[email protected]',
    subject: 'Hello World!',
    body: 'Hello body!',
    article_send: 1
  },
  attachment: {
    tempfile: Rack::Test::UploadedFile.new('spec/support/files/test.pdf')
  }
}

result = Tessera::Ticket.create(params)

OR with multiple attachments:

params = {
  ticket: {
    title: 'New ticket',
    queue: 2,
    state: 'new',
    priority: 3,
    customer_user: 'andrej',
    customer_id: 'aaaaa'
  },
  article: {
    from: '[email protected]',
    subject: 'Hello World!',
    body: 'Hello body!',
  },
  attachment: [
    {
      tempfile: Rack::Test::UploadedFile.new('spec/support/files/test.pdf')
    },
    {
      tempfile: Rack::Test::UploadedFile.new('spec/support/files/test2.pdf')
    }
  ]
}

result = Tessera::Ticket.create(params)

or creating tickets with specific usage of sending article created to To recipients like so:

params = {
  ticket: {
    title: 'New ticket',
    queue: 2,
    state: 'new',
    priority: 3,
    customer_user: 'andrej',
    customer_id: 'aaaaa'
  },
  article: {
    from: '[email protected]',
    to: '[email protected], [email protected]',
    subject: 'Hello World!',
    body: 'Hello body!',
    article_send: 1
  }
}

result = Tessera::Ticket.create(params)

NOTE: this sending of article To email is not done purely by OTRS, you will have to user this plugin: https://github.com/znuny/Znuny4OTRS-GIArticleSend

Please see instalation notes provided by https://github.com/znuny/Znuny4OTRS-Rep

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/tessera. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

TODO

Unfinished or stuff that needs adjusting:

  • Webservice name to configuration (or default from project yml file)
  • Update existing ticket not implemented

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Tessera project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

tessera's People

Contributors

redrick avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tessera's Issues

Unclear error message

When run:

ticket = Tessera::Ticket.find(441031)

I get:

/var/lib/gems/2.4.0/gems/tessera-1.0.0/lib/tessera/ticket.rb:20:in `find': undefined method `first' for nil:NilClass (NoMethodError)
	from /srv/www/testboard/jobs/otrs.rb:13:in `<main>'

It could be permission problem since I have read-only permission on this ticket...anyway I expected error message from server.

Thank you;)

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.