post2zendesk 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +31 -0
- data/bin/post2zendesk +3 -0
- data/lib/commandline.rb +12 -0
- data/lib/post2zendesk.rb +57 -0
- metadata +62 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: d0efc44f4c73daddccbd1da3061b3f9961f0d6f1
|
|
4
|
+
data.tar.gz: d9d34de1a58f25eb1d3db401acb0d0ed5973fdd8
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 23c2c5f042aafc42f984de1f176973fac2cbcf45a23b694e61458f96e7ddb5489875b7160a2bdc677c9783ed6b1404ea24215642e60768d74bff1c9c2945b4bd
|
|
7
|
+
data.tar.gz: 76983f74901323b1d38637b7f2e02425b65523c257e433d8ee13b319319d8b1f8f0b235fe4321b0300e6525533e836a3485aa947daf54df7a2e4b3dcb6e08baf
|
data/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# post2zendesk
|
|
2
|
+
|
|
3
|
+
This gem lets you post a comment to a zendesk ticket, and sets the ticket's status to pending.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
There's only two ways to use it:
|
|
8
|
+
|
|
9
|
+
Inline Comment: `post2zendesk <ticketid> <comment>`
|
|
10
|
+
Stdin Comment: `cat somefile | post2zendesk <ticketid>
|
|
11
|
+
|
|
12
|
+
E.g.:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
lolcalhost$ post2zendesk 4698 'A comment.'
|
|
16
|
+
Ticket 4698 updated. Probably.
|
|
17
|
+
Status: pending
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Configuration
|
|
21
|
+
|
|
22
|
+
You'll need to supply your Zendesk URL, username, and password,
|
|
23
|
+
|
|
24
|
+
Configure via `~/.post2zendesk.yaml`:
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
---
|
|
28
|
+
baseurl: 'support.puppetlabs.com'
|
|
29
|
+
username: 'zachary@puppetlabs.com'
|
|
30
|
+
password: 'mypassword'
|
|
31
|
+
```
|
data/bin/post2zendesk
ADDED
data/lib/commandline.rb
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require 'post2zendesk'
|
|
2
|
+
|
|
3
|
+
put_text_inside_me = Post2Zendesk.new
|
|
4
|
+
|
|
5
|
+
def comment_via_stdin_or_pipe
|
|
6
|
+
return (STDIN.tty? ? ARGV[1] : STDIN.read)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
comment = comment_via_stdin_or_pipe
|
|
10
|
+
|
|
11
|
+
put_text_inside_me.updateticket(ARGV[0], comment)
|
|
12
|
+
put_text_inside_me.printreply
|
data/lib/post2zendesk.rb
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
class Post2Zendesk
|
|
4
|
+
|
|
5
|
+
require 'net/http'
|
|
6
|
+
require 'net/https'
|
|
7
|
+
require 'yaml'
|
|
8
|
+
require 'json'
|
|
9
|
+
require 'uri'
|
|
10
|
+
|
|
11
|
+
def initialize
|
|
12
|
+
configdata = YAML.load_file(ENV['HOME'] + '/.post2zendesk.yaml')
|
|
13
|
+
@uri = URI.parse("https://#{configdata['baseurl']}/")
|
|
14
|
+
@username = configdata['username']
|
|
15
|
+
@password = configdata['password']
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def makerequest(type='Get', body='')
|
|
19
|
+
@http = Net::HTTP.new(@uri.host, @uri.port)
|
|
20
|
+
@http.use_ssl = true
|
|
21
|
+
@http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
22
|
+
|
|
23
|
+
if type == 'Get'
|
|
24
|
+
@request = Net::HTTP::Get.new(@uri.request_uri)
|
|
25
|
+
elsif type == 'Put'
|
|
26
|
+
@request = Net::HTTP::Put.new(@uri.request_uri)
|
|
27
|
+
@request['Content-Type'] = 'application/json'
|
|
28
|
+
@request.body = body
|
|
29
|
+
else
|
|
30
|
+
raise ArgumentError.new('Unrecognized HTTP request type.')
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
@request.basic_auth(@username, @password)
|
|
34
|
+
return @response = @http.request(@request).body
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def updateticket(ticketid, comment, status='pending', is_public='true')
|
|
38
|
+
# https://support.puppetlabs.com/api/v2/tickets/3717.json
|
|
39
|
+
@uri.path = "/api/v2/tickets/#{ticketid.to_s}.json"
|
|
40
|
+
|
|
41
|
+
updatearray = {
|
|
42
|
+
'ticket' => {
|
|
43
|
+
'status' => status,
|
|
44
|
+
'comment' => { 'body' => comment, 'public' => is_public }
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
updatearray_json = updatearray.to_json
|
|
48
|
+
@response = makerequest('Put', updatearray_json)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def printreply
|
|
52
|
+
response_hash = JSON.parse(@response)
|
|
53
|
+
puts "Ticket #{response_hash['ticket']['id']} updated. Probably."
|
|
54
|
+
puts "Status: #{response_hash['ticket']['status']}"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: post2zendesk
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Zachary Alex Stern
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-04-01 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: pry
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - '>='
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - '>='
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
description: Post text or text file as comment to Zendesk ticket.
|
|
28
|
+
email: zacharyalexstern@gmail.com
|
|
29
|
+
executables:
|
|
30
|
+
- post2zendesk
|
|
31
|
+
extensions: []
|
|
32
|
+
extra_rdoc_files: []
|
|
33
|
+
files:
|
|
34
|
+
- lib/commandline.rb
|
|
35
|
+
- lib/post2zendesk.rb
|
|
36
|
+
- bin/post2zendesk
|
|
37
|
+
- README.md
|
|
38
|
+
homepage: https://github.com/zacharyalexstern/post2zendesk
|
|
39
|
+
licenses:
|
|
40
|
+
- WTFPL
|
|
41
|
+
metadata: {}
|
|
42
|
+
post_install_message:
|
|
43
|
+
rdoc_options: []
|
|
44
|
+
require_paths:
|
|
45
|
+
- lib
|
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
47
|
+
requirements:
|
|
48
|
+
- - '>='
|
|
49
|
+
- !ruby/object:Gem::Version
|
|
50
|
+
version: '0'
|
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - '>='
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '0'
|
|
56
|
+
requirements: []
|
|
57
|
+
rubyforge_project:
|
|
58
|
+
rubygems_version: 2.0.3
|
|
59
|
+
signing_key:
|
|
60
|
+
specification_version: 4
|
|
61
|
+
summary: Post text or text file as comment to Zendesk ticket
|
|
62
|
+
test_files: []
|