tessera 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c0f3879b8f5f8538b9aa77e1ea3c13429155e33a
4
+ data.tar.gz: dfc52c94f1d2c390f2292d3c695414d8db1640b7
5
+ SHA512:
6
+ metadata.gz: cdfeedc4502f4323df7980ad0ab2871e5c71a87234998ba2f5c66167edfe67c13072867f98a9a658ec6d8b02159ba8d14efa5fdd5e65bc5fff70c742617ca6ce
7
+ data.tar.gz: 7b884d2c4a52ae50422041ac8083917f95c31b94ac4ead6b845736b3e17b16592d417d82866be7b17fab14e3b2661c01bdf464975365610edda34c41a62f7b67
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
@@ -0,0 +1,7 @@
1
+ PreCommit:
2
+ RuboCop:
3
+ enabled: true
4
+ on_warn: fail
5
+
6
+ TrailingWhitespace:
7
+ enabled: true
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,17 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'tessera.gemspec'
4
+ - 'spec/**/*'
5
+ TargetRubyVersion: 2.3
6
+
7
+ Style/FrozenStringLiteralComment:
8
+ Enabled: false
9
+
10
+ Metrics/LineLength:
11
+ Max: 89
12
+
13
+ Documentation:
14
+ Enabled: false
15
+
16
+ Style/VariableName:
17
+ Enabled: false
@@ -0,0 +1 @@
1
+ tessera
@@ -0,0 +1 @@
1
+ 2.3.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at andrej@antas.cz. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Andrej Antas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,179 @@
1
+ # Tessera
2
+
3
+ This gem is intended as JSON API wrapper for OTRS 6.
4
+
5
+ Documentation of this API with `curl` examples can be found [here](http://doc.otrs.com/doc/manual/admin/5.0/en/html/genericinterface.html#id-1.6.12.10.7.4)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'tessera'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install tessera
22
+
23
+ ## Usage
24
+
25
+ First of all you have to setup your creadentials like so:
26
+
27
+ ```ruby
28
+ Tessera.configure do |config|
29
+ config.username = 'jon'
30
+ config.password = 'SuperSecret'
31
+ config.base_url = 'https://otrs.com/otrs/nph-genericinterface.pl/Webservice/rest/'
32
+ end
33
+ ```
34
+
35
+ Now you also have to load yourself webservice yml file locate [here](https://github.com/redrick/tessera/blob/master/templates/ticket.yml)
36
+ Please do use one enclosed with this gem from github since name of the
37
+ webservice is hardcoded for now, will appear in TODO section for further
38
+ adjustments...
39
+
40
+ Gem provides you `Tessera::Ticket` class to use now with following methods:
41
+
42
+ ### FIND
43
+
44
+ You can find ticket by its ID or by array of IDS like so:
45
+
46
+ ```ruby
47
+ ticket = Tessera::Ticket.find(1)
48
+ tickets = Tessera::Ticket.find([1, 2, 3])
49
+ ```
50
+
51
+ ### WHERE
52
+
53
+ You can search through tickets like so:
54
+
55
+ ```ruby
56
+ results = Tessera::Ticket.where(Title: 'Whic%')
57
+ ```
58
+
59
+ for the list of all available options to search through you can see [this
60
+ page](http://doc.otrs.com/doc/api/otrs/6.0/Perl/Kernel/GenericInterface/Operation/Ticket/TicketSearch.pm.html)
61
+
62
+ Following where call you get the results object on which you can either choose
63
+ if you want array of Tickets or you are just interested in count of them:
64
+
65
+ ```ruby
66
+ results.tickets
67
+
68
+ results.count
69
+ ```
70
+
71
+ ### CREATE
72
+
73
+ You can create new ticket like so:
74
+
75
+ ```ruby
76
+ params = {
77
+ ticket: {
78
+ title: 'New ticket',
79
+ queue: 2,
80
+ state: 'new',
81
+ priority: 3,
82
+ customer_user: 'andrej',
83
+ customer_id: 'aaaaa'
84
+ },
85
+ article: {
86
+ from: 'sender@gmail.com',
87
+ to: 'receiver@destination.com',
88
+ subject: 'Hello World!',
89
+ body: 'Hello body!',
90
+ article_send: 1
91
+ },
92
+ attachment: {
93
+ tempfile: Rack::Test::UploadedFile.new('spec/support/files/test.pdf')
94
+ }
95
+ }
96
+
97
+ result = Tessera::Ticket.create(params)
98
+ ```
99
+
100
+
101
+ OR with multiple attachments:
102
+
103
+ ```ruby
104
+ params = {
105
+ ticket: {
106
+ title: 'New ticket',
107
+ queue: 2,
108
+ state: 'new',
109
+ priority: 3,
110
+ customer_user: 'andrej',
111
+ customer_id: 'aaaaa'
112
+ },
113
+ article: {
114
+ from: 'sender@gmail.com',
115
+ subject: 'Hello World!',
116
+ body: 'Hello body!',
117
+ },
118
+ attachment: [
119
+ {
120
+ tempfile: Rack::Test::UploadedFile.new('spec/support/files/test.pdf')
121
+ },
122
+ {
123
+ tempfile: Rack::Test::UploadedFile.new('spec/support/files/test2.pdf')
124
+ }
125
+ ]
126
+ }
127
+
128
+ result = Tessera::Ticket.create(params)
129
+ ```
130
+
131
+ or creating tickets with specific usage of sending article created to `To`
132
+ recipients like so:
133
+
134
+ ```ruby
135
+ params = {
136
+ ticket: {
137
+ title: 'New ticket',
138
+ queue: 2,
139
+ state: 'new',
140
+ priority: 3,
141
+ customer_user: 'andrej',
142
+ customer_id: 'aaaaa'
143
+ },
144
+ article: {
145
+ from: 'sender@gmail.com',
146
+ to: 'receiver@destination.com, second@email.com',
147
+ subject: 'Hello World!',
148
+ body: 'Hello body!',
149
+ article_send: 1
150
+ }
151
+ }
152
+
153
+ result = Tessera::Ticket.create(params)
154
+ ```
155
+
156
+
157
+ ## Development
158
+
159
+ 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.
160
+
161
+ 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](https://rubygems.org).
162
+
163
+ ## Contributing
164
+
165
+ 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](http://contributor-covenant.org) code of conduct.
166
+
167
+ ## TODO
168
+
169
+ Unfinished or stuff that needs adjusting:
170
+ * Webservice name to configuration (or default from project yml file)
171
+ * Update existing ticket not implemented
172
+
173
+ ## License
174
+
175
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
176
+
177
+ ## Code of Conduct
178
+
179
+ Everyone interacting in the Tessera project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/tessera/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1 @@
1
+ theme: jekyll-theme-slate
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'tessera'
5
+ require 'pry'
6
+ Pry.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,55 @@
1
+ ##
2
+ #
3
+ # requires outside this gem folder
4
+ #
5
+ require 'net/http'
6
+ require 'json'
7
+ require 'base64'
8
+
9
+ ##
10
+ #
11
+ # requires of this gem classes
12
+ #
13
+ require 'tessera/version'
14
+ require 'tessera/configuration'
15
+
16
+ require 'tessera/utils/errors'
17
+
18
+ require 'tessera/request'
19
+
20
+ require 'tessera/api/session'
21
+ require 'tessera/api/ticket_get'
22
+ require 'tessera/api/ticket_list'
23
+ require 'tessera/api/ticket_search'
24
+ require 'tessera/api/ticket_create'
25
+
26
+ require 'tessera/model/base'
27
+ require 'tessera/model/session'
28
+ require 'tessera/model/ticket'
29
+
30
+ require 'tessera/otrs/base'
31
+ require 'tessera/otrs/ticket'
32
+ require 'tessera/otrs/article'
33
+ require 'tessera/otrs/attachment'
34
+
35
+ require 'tessera/ticket'
36
+
37
+ ##
38
+ #
39
+ # Main module of OTRS wrapper
40
+ #
41
+ # See 'tessera/configuration.rb' for more explanation how to set configuration
42
+ #
43
+ module Tessera
44
+ def self.configuration
45
+ @configuration ||= Configuration.new
46
+ end
47
+
48
+ def self.reset
49
+ @configuration = Configuration.new
50
+ end
51
+
52
+ def self.configure
53
+ yield(configuration)
54
+ end
55
+ end
@@ -0,0 +1,27 @@
1
+ ##
2
+ #
3
+ #
4
+ #
5
+ module Tessera
6
+ module Api
7
+ class Session
8
+ def self.create
9
+ new.create
10
+ end
11
+
12
+ def create
13
+ response = Tessera::Request.new(:post, 'Session', credentials).send
14
+ Tessera::Model::Session.new(response)
15
+ end
16
+
17
+ private
18
+
19
+ def credentials
20
+ {
21
+ UserLogin: Tessera.configuration.username,
22
+ Password: Tessera.configuration.password
23
+ }
24
+ end
25
+ end
26
+ end
27
+ end