ticket_abstractor_client 0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,93 @@
1
+ # TicketAbstractorClient
2
+
3
+ Client for accessing to a TicketAbstractor service.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'ticket_abstractor_client'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install ticket_abstractor_client
18
+
19
+ ## Usage
20
+
21
+ Initialize:
22
+
23
+ client = TicketAbstractorClient.initialize_client('http://ticket.abstractor.url')
24
+
25
+ Access clients:
26
+
27
+ client.jira
28
+ client.brouha
29
+ client.itrc
30
+
31
+ ### Jira
32
+
33
+ Grab issue:
34
+
35
+ client.jira.get_issue 'IFS-123'
36
+ client.jira.get_issue_status 'IFS-123' => 'Open'
37
+
38
+ Create issue (summary, description and issuetype fields are required):
39
+
40
+ options = { project: "IFS", summary: "Summary", description: "Desc", issuetype: "Bug"}
41
+ client.jira.create_issue options
42
+
43
+ Create issue with an attachment:
44
+
45
+ options = { project: "IFS", summary: "Summary", description: "Desc", issuetype: "Bug"}
46
+ attachment = File.new('file.png', 'rb')
47
+ client.jira.create_issue options, attachment
48
+
49
+ Update issue (issuekey field is required):
50
+
51
+ client.jira.update_issue({ issuekey: 'IFS-46728', description: 'new description' })
52
+
53
+ Attach the file to issue:
54
+
55
+ attachment = File.new('file.png', 'rb')
56
+ client.jira.update_issue({ issuekey: 'IFS-46728' }, attachment)
57
+
58
+ ### Brouha
59
+
60
+ Grab issue:
61
+
62
+ client.brouha.get_issue '12'
63
+
64
+ ### iTRC
65
+
66
+ Find apps:
67
+
68
+ client.itrc.list_apps
69
+ client.itrc.find_app 'itrc'
70
+
71
+ Find app_groups:
72
+
73
+ client.itrc.list_app_groups
74
+ client.itrc.find_app_group 'app-mgmt-tools'
75
+
76
+ Find business units:
77
+
78
+ client.itrc.list_business_units
79
+ client.itrc.find_business_unit 3
80
+
81
+ Find departments:
82
+
83
+ client.itrc.list_departments
84
+ client.itrc.find_department 4
85
+
86
+
87
+ ## Contributing
88
+
89
+ 1. Fork it
90
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
91
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
92
+ 4. Push to the branch (`git push origin my-new-feature`)
93
+ 5. Create new Pull Request
@@ -0,0 +1,5 @@
1
+ class TicketAbstractorClient::BrouhaClient < TicketAbstractorClient::Client
2
+ def get_issue(issue_key)
3
+ get "ticket/brouha/#{issue_key}"
4
+ end
5
+ end
@@ -0,0 +1,19 @@
1
+ class TicketAbstractorClient::Client
2
+ def initialize(base_url)
3
+ @base_url = base_url
4
+ end
5
+
6
+ def get(url, args = {}, params = {})
7
+ params.merge! args: args.to_json
8
+ response = RestClient.get("#{@base_url}/#{url}", params: params)
9
+
10
+ JSON.parse response
11
+ end
12
+
13
+ def post(url, args = {}, params = {})
14
+ params.merge! args: args.to_json
15
+ response = RestClient.post("#{@base_url}/#{url}", params)
16
+
17
+ JSON.parse response
18
+ end
19
+ end
@@ -0,0 +1,33 @@
1
+ class TicketAbstractorClient::ItrcClient < TicketAbstractorClient::Client
2
+ def list_apps(page = 1, per_page = 20)
3
+ get 'itrc/list_apps', page: page, per_page: per_page
4
+ end
5
+
6
+ def find_app(id)
7
+ get 'itrc/find_app', id: id
8
+ end
9
+
10
+ def list_app_groups(page = 1, per_page = 20)
11
+ get 'itrc/list_app_groups', page: page, per_page: per_page
12
+ end
13
+
14
+ def find_app_group(id)
15
+ get 'itrc/find_app_group', id: id
16
+ end
17
+
18
+ def list_business_units(page = 1, per_page = 20)
19
+ get 'itrc/list_business_units', page: page, per_page: per_page
20
+ end
21
+
22
+ def find_business_unit(id)
23
+ get 'itrc/find_business_unit', id: id
24
+ end
25
+
26
+ def list_departments(page = 1, per_page = 20)
27
+ get 'itrc/list_departments', page: page, per_page: per_page
28
+ end
29
+
30
+ def find_department(id)
31
+ get 'itrc/find_department', id: id
32
+ end
33
+ end
@@ -0,0 +1,71 @@
1
+ class TicketAbstractorClient::JiraClient < TicketAbstractorClient::Client
2
+ ##
3
+ # Get jira issue by issue id
4
+ #
5
+ # == Parameters:
6
+ # issue_key:
7
+ # issue id in jira
8
+ #
9
+ # == Example:
10
+ # >> client.jira.get_issue 'IFS-123'
11
+ # => { 'id' => 'IFS-123', 'description' => '...', ... }
12
+ def get_issue(issue_key)
13
+ get "ticket/jira/#{issue_key}"
14
+ end
15
+
16
+ ##
17
+ # Get the status of jira issue by issue id
18
+ #
19
+ # == Parameters:
20
+ # issue_key:
21
+ # issue id in jira
22
+ #
23
+ # == Example:
24
+ # >> client.jira.get_issue_status 'IFS-123'
25
+ # => 'Resolved'
26
+ def get_issue_status(issue_key)
27
+ get_issue(issue_key)['status']
28
+ end
29
+
30
+ def get_issues_by_query(query)
31
+ get 'jira/get_issues_by_query', query: query
32
+ end
33
+
34
+ def get_users_by_query(query)
35
+ get 'jira/get_users_by_query', query: query
36
+ end
37
+
38
+ def get_issues_statuses_by_search_query(issues_id)
39
+ get 'jira/get_issues_statuses_by_search_query', issues_id: issues_id
40
+ end
41
+
42
+ ##
43
+ # Get issues by jira filter
44
+ #
45
+ # == Parameters:
46
+ # filter_id:
47
+ # filter id in jira
48
+ #
49
+ # == Example:
50
+ # >> client.jira.get_issues_by_filter 24320
51
+ # => [{ 'id' => 'ID-1', ... }, { 'id' => 'ID-2', ... }]
52
+ def get_issues_by_filter(filter_id)
53
+ get 'jira/get_issues_by_filter', filter_id: filter_id
54
+ end
55
+
56
+ def get_fields_by_project(project_key)
57
+ get 'jira/get_fields_by_project', project_key: project_key
58
+ end
59
+
60
+ def create_issue(opts = {}, *attachments)
61
+ post('jira/create_issue', { opts: opts }, attachments: attachments)
62
+ end
63
+
64
+ def update_issue(opts = {}, *attachments)
65
+ post('jira/update_issue', { opts: opts }, attachments: attachments)
66
+ end
67
+
68
+ def add_comment(issue_key, comment)
69
+ post 'jira/add_comment', issue_key: issue_key, comment: comment
70
+ end
71
+ end
@@ -0,0 +1,3 @@
1
+ module TicketAbstractorClient
2
+ VERSION = '0.1'
3
+ end
@@ -0,0 +1,25 @@
1
+ module TicketAbstractorClient
2
+ def self.initialize_client(url)
3
+ @url = url
4
+ self
5
+ end
6
+
7
+ def self.jira
8
+ @jira_client ||= JiraClient.new(@url)
9
+ end
10
+
11
+ def self.brouha
12
+ @brouha_client ||= BrouhaClient.new(@url)
13
+ end
14
+
15
+ def self.itrc
16
+ @itrc ||= ItrcClient.new(@url)
17
+ end
18
+ end
19
+
20
+ require 'rest_client'
21
+ require 'ticket_abstractor_client/version'
22
+ require 'ticket_abstractor_client/client'
23
+ require 'ticket_abstractor_client/jira_client'
24
+ require 'ticket_abstractor_client/brouha_client'
25
+ require 'ticket_abstractor_client/itrc_client'
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ticket_abstractor_client
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - rsamoilov
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-02-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rest-client
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.6.7
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.6.7
62
+ description: Get access to Jira and Brouha ticketing systems through the single service
63
+ email:
64
+ - rsamoilov@productengine.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - lib/ticket_abstractor_client.rb
70
+ - lib/ticket_abstractor_client/jira_client.rb
71
+ - lib/ticket_abstractor_client/itrc_client.rb
72
+ - lib/ticket_abstractor_client/brouha_client.rb
73
+ - lib/ticket_abstractor_client/client.rb
74
+ - lib/ticket_abstractor_client/version.rb
75
+ - README.md
76
+ homepage: http://github.com/rsamoilov/ticket_abstractor_client
77
+ licenses:
78
+ - MIT
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 1.8.25
98
+ signing_key:
99
+ specification_version: 3
100
+ summary: Client for the Ticket Abstractor service
101
+ test_files: []