bugherd_client 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8bc66534748aeba97dd104812c820c8c386b3cdb
4
- data.tar.gz: 8b21ec8ef3a8e372fa7d2f36a23c7958f7378251
3
+ metadata.gz: a0bcd4453cc95825470d7c96cd95a694dc4942bd
4
+ data.tar.gz: d3a15e2ac22b153ae89fabf103a7c8123f4a2d5c
5
5
  SHA512:
6
- metadata.gz: 9667fd201184c2cfedc7574570a5a3df73bf7fdd03cbd104fdbcb807d5ad48ee1b056db40e861c3a1da2d9ae9159ecc962874cb0d2367bbc5bd925fa87103ada
7
- data.tar.gz: 17ce74ba5e174e91cd08354795eb37aa9393c75a87c40456438e818148a1075d9420c63465c37ec6f2d4687d4555f8c352c3fabfa65e63d7da5a5674b623011b
6
+ metadata.gz: ffd91b8c06845d81ea2d86210e927b1e678bbed9ef931b9d3cfda2e0af9ed04a043847f9714dd4ad5ebf5d3038181f920c4aecd4e49085f8552952ee58eab8b2
7
+ data.tar.gz: 980f304b6c230cfcd048d67c8d7bcd3f10bae346906d543327493850acd2be7bfc1508c572e3eabf764943cbd7437a6f96ddaa56d1e6fe172429dbc754f77e95
@@ -11,6 +11,7 @@ module BugherdClient
11
11
  username: '',
12
12
  password: '',
13
13
  api_key: '',
14
+ api_rate_limiting_token: 'x',
14
15
  debug: false
15
16
  }
16
17
 
@@ -27,8 +28,8 @@ module BugherdClient
27
28
  username, password = build_credentials
28
29
 
29
30
  if @options[:debug]
30
- RestClient.log = ::Logger.new($stderr)
31
- RestClient.log.level = Logger::DEBUG
31
+ RestClient.log = ::Logger.new($stderr)
32
+ RestClient.log.level = ::Logger::DEBUG
32
33
  end
33
34
 
34
35
  self.connection = RestClient::Resource.new(base_url, user: username, password: password)
@@ -50,7 +51,7 @@ module BugherdClient
50
51
 
51
52
  def build_credentials
52
53
  if @options[:api_key]
53
- [@options[:api_key], 'x']
54
+ [@options[:api_key], @options[:api_rate_limiting_token]]
54
55
  else
55
56
  [@options[:username], @options[:password]]
56
57
  end
@@ -7,6 +7,12 @@ module BugherdClient
7
7
  end
8
8
  end
9
9
 
10
+ class NotAvailable < StandardError
11
+ def initialize(api_version, msg="")
12
+ super("#{msg} not available in API v#{api_version}")
13
+ end
14
+ end
15
+
10
16
  class UnsupportedMethod < StandardError
11
17
  def initialize(api_version="")
12
18
  super("Method supported in API version #{api_version}")
@@ -2,7 +2,7 @@ module BugherdClient
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- PATCH = 4
5
+ PATCH = 5
6
6
 
7
7
  STRING = [MAJOR,MINOR,PATCH].join('.')
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bugherd_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Faucett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-07 00:00:00.000000000 Z
11
+ date: 2014-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -102,12 +102,6 @@ files:
102
102
  - lib/bugherd_client.rb
103
103
  - lib/bugherd_client/client.rb
104
104
  - lib/bugherd_client/errors.rb
105
- - lib/bugherd_client/resources/base.rb
106
- - lib/bugherd_client/resources/comment.rb
107
- - lib/bugherd_client/resources/organization.rb
108
- - lib/bugherd_client/resources/project.rb
109
- - lib/bugherd_client/resources/task.rb
110
- - lib/bugherd_client/resources/user.rb
111
105
  - lib/bugherd_client/resources/v1/base.rb
112
106
  - lib/bugherd_client/resources/v1/comment.rb
113
107
  - lib/bugherd_client/resources/v1/project.rb
@@ -1,36 +0,0 @@
1
- require 'json'
2
-
3
- module BugherdClient
4
- module Resources
5
- class Base
6
-
7
- DEFAULT_HEADERS = { content_type: :json, accept: :json }
8
-
9
- attr_accessor :connection, :options
10
- def initialize(conn, opts={})
11
- @connection, @options = conn, opts
12
- end
13
-
14
- def send_request(method="GET", path="", params={}, headers={})
15
- headers = DEFAULT_HEADERS.merge(headers)
16
- params.merge!(headers)
17
- method_name = method.to_s.downcase
18
- self.connection[path].__send__(method_name, params)
19
- end
20
-
21
- [:get, :post, :put, :patch, :delete].each do |method_name|
22
- define_method("#{method_name}_request") do |path, params={}|
23
- send_request(method_name, path, params)
24
- end
25
- end
26
-
27
- def parse_response(response, root_element=nil)
28
- if root_element
29
- JSON.parse(response)[root_element.to_s]
30
- else
31
- JSON.parse(response)
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,23 +0,0 @@
1
- module BugherdClient
2
- module Resources
3
- class Comment < Base
4
-
5
- #
6
- # Get a paginated list of comments for a task.
7
- #
8
- def all(project_id, task_id)
9
- raw_response = get_request("projects/#{project_id}/tasks/#{task_id}/comments")
10
- parse_response(raw_response, :comments)
11
- end
12
-
13
- #
14
- # Create a comment
15
- # attributes: text, user_id or email
16
- def create(project_id, task_id, attributes={})
17
- raw_response = post_request("projects/#{project_id}/tasks/#{task_id}/comments", comment: attributes)
18
- parse_response(raw_response)
19
- end
20
-
21
- end
22
- end
23
- end
@@ -1,14 +0,0 @@
1
- module BugherdClient
2
- module Resources
3
- class Organization < Base
4
-
5
- #
6
- # Get more detail of your account.
7
- #
8
- def get
9
- raw_response = self.connection['organization'].get
10
- parse_response(raw_response, :organization)
11
- end
12
- end
13
- end
14
- end
@@ -1,76 +0,0 @@
1
- module BugherdClient
2
- module Resources
3
- class Project < Base
4
-
5
- #
6
- # Get more detail of your account.
7
- #
8
- def all
9
- raw_response = get_request('projects')
10
- parse_response(raw_response, :projects)
11
- end
12
-
13
- #
14
- # Show details for a specific project
15
- #
16
- def find(project_id)
17
- raw_response = get_request("projects/#{project_id}")
18
- parse_response(raw_response, :project)
19
- end
20
-
21
- #
22
- # Create a Project, will initially have no members
23
- # attributes: name, devurl, is_public, is_active
24
- #
25
- def create(attributes={})
26
- raw_response = post_request("projects", project: attributes)
27
- parse_response(raw_response, :project)
28
- end
29
-
30
- #
31
- # Update settings for an existing project under your control (ie: only the ones you own).
32
- # API: 1,2
33
- def update(project_id, attributes={})
34
- raw_response = put_request("projects/#{project_id}", project: attributes)
35
- parse_response(raw_response, :project)
36
- end
37
-
38
- #
39
- # Delete a project and all associated data. Use with care, deleted projects cannot be recovered.
40
- # API: 1,2
41
- def delete(project_id)
42
- raw_response = delete_request("projects/#{project_id}")
43
- parse_response(raw_response)
44
- end
45
-
46
- #
47
- # Add an existing guest to a project, or invite someone by email address.
48
- # required: project_id
49
- # attributes: user_id, email
50
- # API: 2
51
- def add_guest(project_id, attributes={})
52
- raw_response = post_request("projects/#{project_id}/add_guest", attributes)
53
- parse_response(raw_response)
54
- end
55
-
56
- #
57
- # Add an existing guest to a project, or invite someone by email address.
58
- # required: project_id
59
- # attributes: user_id
60
- #
61
- def add_member(project_id, attributes={})
62
- raw_response = post_request("projects/#{project_id}/add_member", attributes)
63
- parse_response(raw_response)
64
- end
65
-
66
-
67
- #
68
- # Get all active projects
69
- #
70
- def active
71
- raw_response = get_request('projects/active')
72
- parse_response(raw_response, :projects)
73
- end
74
- end
75
- end
76
- end
@@ -1,56 +0,0 @@
1
- module BugherdClient
2
- module Resources
3
- class Task < Base
4
-
5
- PRIORITIES = ['not set', 'critical', 'important', 'normal','minor']
6
- PRIORITIES.each do |priority|
7
- Task.const_set("PRIORITY_#{priority.gsub(' ', '').upcase}", priority)
8
- end
9
-
10
- STATUSES = ['backlog','todo','doing','done','closed']
11
- STATUSES.each do |status|
12
- Task.const_set("STATUS_#{status.upcase}", status)
13
- end
14
-
15
- #
16
- # Get a full list of tasks for a project, including archived tasks.
17
- # filters: updated_since, created_since, status, priority, tag and external_id
18
- def all(project_id, filter_attributes={})
19
- params = filter_attributes.empty? ? {} : { params: filter_attributes }
20
- raw_response = get_request("projects/#{project_id}/tasks", params)
21
- parse_response(raw_response, :tasks)
22
- end
23
-
24
- #
25
- # List details of a task in a given project, includes all data including comments, attachments, etc.
26
- #
27
- def find(project_id, task_id)
28
- raw_response = get_request("projects/#{project_id}/tasks/#{task_id}")
29
- parse_response(raw_response)
30
- end
31
-
32
- #
33
- # Create a new Task
34
- # attributes:
35
- # description, priority, status, tag_names(Array),
36
- # requester_id or requester_email,
37
- # assigned_to_id or assigned_to_email
38
- # external_id
39
- # if status is null the Task is automatically put in the Feedback panel
40
- # "requester_email" can be any email address while "assigned_to_email" needs to be of a current project member.
41
- # Values for "priority" are not set, critical, important, normal, and minor.
42
- # Values for "status" are backlog, todo, doing, done, and closed. Omit this field or set as "null" to send tasks to the Feedback panel.
43
- # External ID is an API-only field. It cannot be set from the BugHerd application, only using the API. An external ID can be used to track originating IDs from other systems in BugHerd bugs.
44
- def create(project_id, attributes={})
45
- raw_response = post_request("projects/#{project_id}/tasks", task: attributes)
46
- parse_response(raw_response)
47
- end
48
-
49
- def update(project_id, task_id, attributes={})
50
- raw_response = put_request("projects/#{project_id}/tasks/#{task_id}", task: attributes)
51
- parse_response(raw_response)
52
- end
53
-
54
- end
55
- end
56
- end
@@ -1,31 +0,0 @@
1
- module BugherdClient
2
- module Resources
3
- class User < Base
4
-
5
- #
6
- # See all the people in your account.
7
- # API: 1,2
8
- def all
9
- raw_response = get_request('users')
10
- parse_response(raw_response, :users)
11
- end
12
-
13
- #
14
- # See all your account members
15
- #
16
- def members
17
- raw_response = get_request('users/members')
18
- parse_response(raw_response, :users)
19
- end
20
-
21
- #
22
- # See all the guest in your account
23
- #
24
- def guests
25
- raw_response = get_request('users/guests')
26
- parse_response(raw_response, :users)
27
- end
28
-
29
- end
30
- end
31
- end