ticksy_api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c398c646e5ce7ed70cfb2d970781f3e785feb357
4
+ data.tar.gz: 9817aa1ddd49cf5e7d3ceec37cd2dbf93516a250
5
+ SHA512:
6
+ metadata.gz: 7a9b08e52867ffa7895e9c48174b514fa06b3ecc70661b69a942154866e4ef8855ee2b779cffd487d5435d4607f800c0a77e4b6d4bd5b90ea8ca78d2094ec6e1
7
+ data.tar.gz: ebfda7d9d0876eaf3a6add54b8b2a332ca1ead72447b22b219d35b81d7b3d8d37889d07577143aaa29ee4b93e8384f582018f9585b78c834a6460032ca3936e8
@@ -0,0 +1,44 @@
1
+ module TicksyAPI
2
+ class Client
3
+ def initialize(domain, key)
4
+ @domain = domain
5
+ @key = key
6
+ end
7
+
8
+ def my_tickets
9
+ execute('my-tickets')['my-tickets'].map { |data| Ticket.new data, self }
10
+ end
11
+
12
+ def open_tickets
13
+ execute('open-tickets')['open-tickets'].map { |data| Ticket.new data, self }
14
+ end
15
+
16
+ def closed_tickets
17
+ execute('closed-tickets')['closed-tickets'].map { |data| Ticket.new data, self }
18
+ end
19
+
20
+ def my_responses_needed
21
+ execute('my-responses-needed')['responses-needed'].to_i
22
+ end
23
+
24
+ def responses_needed
25
+ execute('responses-needed')['responses-needed'].to_i
26
+ end
27
+
28
+ def ticket_comments(id)
29
+ execute('ticket-comments', id)['ticket-comments'].map { |data| Comment.new data }
30
+ end
31
+
32
+ private
33
+
34
+ def execute(endpoint, param = nil)
35
+ response = JSON.parse RestClient.get "https://api.ticksy.com/v1/#{@domain}/#{@key}/#{endpoint}.json/#{param}"
36
+
37
+ if response['error']
38
+ raise Error.new response['error']
39
+ end
40
+
41
+ response
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,4 @@
1
+ module TicksyAPI
2
+ class Comment < OpenStruct
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module TicksyAPI
2
+ class Error < StandardError
3
+ end
4
+ end
@@ -0,0 +1,13 @@
1
+ module TicksyAPI
2
+ class Ticket < OpenStruct
3
+ def initialize(data, client)
4
+ super data
5
+
6
+ @client = client
7
+ end
8
+
9
+ def comments
10
+ @client.ticket_comments ticket_id
11
+ end
12
+ end
13
+ end
data/lib/ticksy_api.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'rest-client'
2
+ require 'json'
3
+ require 'ostruct'
4
+
5
+ require File.dirname(__FILE__) + '/ticksy_api/client'
6
+ require File.dirname(__FILE__) + '/ticksy_api/comment'
7
+ require File.dirname(__FILE__) + '/ticksy_api/ticket'
8
+ require File.dirname(__FILE__) + '/ticksy_api/error'
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ticksy_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael De Wildt
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description:
28
+ email: hello@influx.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/ticksy_api.rb
34
+ - lib/ticksy_api/client.rb
35
+ - lib/ticksy_api/comment.rb
36
+ - lib/ticksy_api/error.rb
37
+ - lib/ticksy_api/ticket.rb
38
+ homepage: https://github.com/influx-inc/ticksy-api-client
39
+ licenses:
40
+ - MIT
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.4.5
59
+ signing_key:
60
+ specification_version: 4
61
+ summary: A Ruby client for the Ticksy API https://ticksy.com/
62
+ test_files: []