easyqa_api 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0371eb9f0345eb50e8f5b65420cbc1dbd57b6b3f
4
- data.tar.gz: 4569839ea9c35f3bed033f1eadc18f7cd77751d0
3
+ metadata.gz: f14e18926cb681afd1078762ae72921b5d0bf2c9
4
+ data.tar.gz: 506e20189751e61f39b9a6f1e71444ca8ec9a4cb
5
5
  SHA512:
6
- metadata.gz: cc38d44ee7a6bb4d2a2130bf336dd4efc6bdf0a0aca22540b2a2d068470dc65ddbb49c0ecac8465f629ade6efd70be321e4c4a1d1304f708c6777e6cd9441c80
7
- data.tar.gz: 3a020b5d1e5b7018b95dd1758daa6b7fb869ae568510581758052e040c01b9b7b0e9bf0e4fee0c7c9eb9f271d6c60301a486c214d5f32aedd6a12727dff7eb6a
6
+ metadata.gz: bab41da387c667eb73694fa39c286d5dc2641ad46cb592bd5a1f69633f955367c44059894efb6b48740ca857eed8bb2e2d8952f6eaf8555475ea84d17d31bef7
7
+ data.tar.gz: e94fe47f43326ca3b3b43ed4d8eb6ad8df8b952a000cf542caeb6c8c09172543359bebc394b19372e08f903a20dd9856c001d8670eb689eeda2aa5404128ba46
@@ -1,8 +1,14 @@
1
+ # Simple gem for EasyQA api
1
2
  module EasyqaApi
3
+ # Saves the default config of gem
2
4
  class Configuration
3
5
  class << self
4
6
  attr_accessor :url, :api_version
5
7
 
8
+ # Generate the valid api path for this api_version
9
+ # @return [String] api path
10
+ # @example
11
+ # EasyqaApi.configuration.api_path #=> '/api/v1/'
6
12
  def api_path
7
13
  "/api/v#{@api_version}/"
8
14
  end
@@ -18,6 +24,12 @@ module EasyqaApi
18
24
 
19
25
  @configuration = Configuration
20
26
 
27
+ # Setup your params.
28
+ # @example You can change default params
29
+ # EasyqaApi.setup do |config|
30
+ # config.url = 'http://app.geteasyqa.com/'
31
+ # config.api_version = 1
32
+ # end
21
33
  def self.setup
22
34
  yield @configuration
23
35
  end
@@ -1,29 +1,46 @@
1
1
  module EasyqaApi
2
- class NotFoundError < StandardError
3
- end
2
+ # Class for processing exceptions
3
+ class Exception
4
+ # Exception for 404 response status
5
+ class NotFoundError < StandardError
6
+ end
4
7
 
5
- class PermissionError < StandardError
6
- end
8
+ # Exception for 403 response status
9
+ class PermissionError < StandardError
10
+ end
7
11
 
8
- class RequestError < StandardError
9
- end
12
+ # Exception for 400 response status
13
+ class RequestError < StandardError
14
+ end
10
15
 
11
- class ValidationError < StandardError
12
- end
16
+ # Exception for 422 response status
17
+ class ValidationError < StandardError
18
+ end
13
19
 
14
- class Exception
20
+ # Constant for quickly find exception class by response status
15
21
  EXCEPTIONS = {
16
- 404 => EasyqaApi::NotFoundError,
17
- 403 => EasyqaApi::PermissionError,
18
- 400 => EasyqaApi::RequestError,
19
- 422 => EasyqaApi::ValidationError
22
+ 404 => NotFoundError,
23
+ 403 => PermissionError,
24
+ 400 => RequestError,
25
+ 422 => ValidationError
20
26
  }.freeze
21
27
 
28
+ # Check response status
29
+ # @param response [Faraday::Response] the response of your request
30
+ # @raise [NotFoundError] if status eql 404
31
+ # @raise [PermissionError] if status eql 403
32
+ # @raise [RequestError] if status eql 400
33
+ # @raise [ValidationError] if status eql 422
34
+ # @see EXCEPTIONS
22
35
  def self.check_response_status!(response)
23
36
  raise EXCEPTIONS[response.status], response.body['message'] || retrieve_mess(response.body) \
24
37
  if EXCEPTIONS[response.status]
25
38
  end
26
39
 
40
+ # Retrieve message by response body
41
+ # @param response_boddy [Hash]
42
+ # @example
43
+ # EasyqaApi::Exception.retrieve_mess({ title: ["can`t be blank"]}) #=> "title: can`t be blank"
27
44
  def self.retrieve_mess(response_boddy)
28
45
  response_boddy.each_with_object('') do |(key, values), result_message|
29
46
  result_message << "#{key}: #{values.join('; ')}\n"
@@ -1,7 +1,18 @@
1
1
  module EasyqaApi
2
+ # This module provides extends instance methods to class
2
3
  module ClassMethodsSettable
4
+ # List of allowed instance methods
3
5
  METHODS = [:create, :show, :update, :delete].freeze
4
6
 
7
+ # Provide instance methods to class
8
+ # @param options [Hash] options for install class methods
9
+ # @option options [Array] :only only few methods from METHODS constant
10
+ # @option options [Array] :except except few methods from METHODS constant
11
+ # @see METHODS
12
+ # @example With only params
13
+ # install_class_methods! only: [:update, :delete]
14
+ # @example With except params
15
+ # install_class_methods! except: [:create]
5
16
  def install_class_methods!(options = {})
6
17
  METHODS.each do |method_name|
7
18
  define_singleton_method method_name do |*attrs|
@@ -1,9 +1,51 @@
1
1
  require 'faraday_middleware'
2
2
 
3
+ # @!macro project_token_param
4
+ # @param project_token [String] token of project
5
+
6
+ # @!macro id_param
7
+ # @param id [String] item id
8
+
9
+ # @!macro auth_user_param
10
+ # @param user [Easyqapi::User] authenticated user in EasyQA
11
+
12
+ # @!macro see_default_user
13
+ # @see @@default_user
14
+
15
+ # @!macro item_action_return
16
+ # Have a class method analog
17
+ # @macro auth_user_param
18
+ # @return [Hash] item attribtues on EasyQA website
19
+ # @see EasyqaApi::ClassMethodsSettable
20
+ # @macro see_default_user
21
+
22
+ # @!macro item_action_return_with_attrs
23
+ # @macro item_action_return
24
+ # @param attrs [Hash] attributes for action
25
+ # @option attrs [String] :project_token (@project_token) Project token on EasyQA
26
+
27
+ # @!macro item_action_return_with_attrs_and_id
28
+ # @macro item_action_return_with_attrs
29
+ # @option attrs [Fixnum] :id (@id) uniq item identeficator
30
+
31
+ # @!macro default_attributes
32
+ # @!attribute [rw] id
33
+ # @return [Fixnum] The uniq identeficator item on EasyQA website
34
+ # @!attribute [rw] attributes
35
+ # @return [Hash] item attributes from response body in your requests
36
+
37
+ # @!macro default_attributes_with_project_token
38
+ # @macro default_attributes
39
+ # @!attribute [rw] project_token
40
+ # @return [String] your project token
3
41
  module EasyqaApi
42
+ # The class for representation EasyQA objects
4
43
  class Item
5
44
  extend ClassMethodsSettable
6
45
 
46
+ # constant for Faradat connection by content type
47
+ # @see EasyqaApi::Item.json_connection
48
+ # @see EasyqaApi::Item.multipart_connection
7
49
  CONNECTION = {
8
50
  json: {
9
51
  instance: -> { json_connection },
@@ -15,7 +57,14 @@ module EasyqaApi
15
57
  }
16
58
  }.freeze
17
59
 
60
+ # Deafult user in EasyqaApi Items.
61
+ # If you set this attributes you can use any methods without set user in all methods
62
+ # @see User#set_default!
63
+ @@default_user = nil
64
+
18
65
  class << self
66
+ # retrieve or create Faraday json connection
67
+ # @return [Faraday::Connection] Faraday json connection
19
68
  def json_connection
20
69
  @json_connection ||= Faraday.new(url: EasyqaApi.configuration.url) do |faraday|
21
70
  faraday.request :json
@@ -24,6 +73,8 @@ module EasyqaApi
24
73
  end
25
74
  end
26
75
 
76
+ # retrieve or create Faraday multipart connection
77
+ # @return [Faraday::Connection] Faraday multipart connection
27
78
  def multipart_connection
28
79
  @multipart_connection ||= Faraday.new(url: EasyqaApi.configuration.url) do |faraday|
29
80
  faraday.request :multipart
@@ -32,6 +83,26 @@ module EasyqaApi
32
83
  end
33
84
  end
34
85
 
86
+ # Send request to EasyQA api within default configuration
87
+ # @param url [String] url for method
88
+ # @param html_method [Symbol] html method for request
89
+ # @param type [Symbol] type of request
90
+ # @yield faraday request config
91
+ # @example
92
+ # send_request('projects', :post) do |req|
93
+ # req.body = {
94
+ # project: {
95
+ # title: 'Test Project'
96
+ # },
97
+ # organization_id: 1,
98
+ # auth_token: 'IcdHzYZXDlX8SsjoOC5MV59lPVPzbaEUuUgZly3ESmopojMaN5pNlzOJCAV2_Rfe'
99
+ # }
100
+ # end
101
+ # @return [Hash] response body
102
+ # @raise [NotFoundError, PermissionError, RequestError, ValidationError] if request fail
103
+ # @see EasyqaApi::Exception.check_response_status!
104
+ # @see CONNECTION
105
+ # @see EasyqaApi::Configuration
35
106
  def send_request(url, html_method, type = :json, &block)
36
107
  response = EasyqaApi::Item::CONNECTION[type][:instance].call.send(html_method) do |req|
37
108
  req.url EasyqaApi.configuration.api_path + url
@@ -42,6 +113,11 @@ module EasyqaApi
42
113
  operation_status(response)
43
114
  end
44
115
 
116
+ # Processing response
117
+ # @param response [Faraday::Response] response of your request
118
+ # @raise [NotFoundError, PermissionError, RequestError, ValidationError] if response not valid
119
+ # @return [Hash] response body
120
+ # @see EasyqaApi::Exception.check_response_status!
45
121
  def operation_status(response)
46
122
  EasyqaApi::Exception.check_response_status!(response)
47
123
  response.body
@@ -51,8 +127,8 @@ module EasyqaApi
51
127
  def initialize(*_args)
52
128
  end
53
129
 
54
- @@default_user = nil
55
-
130
+ # Install variables for Item instance if key in attribute has a valid setter in instance
131
+ # @param arguments [Hash]
56
132
  def install_variables!(arguments)
57
133
  allowed_methods = retrive_allowed_methods
58
134
  arguments.each do |key, value|
@@ -1,9 +1,41 @@
1
+ # @!macro [new] issue_attributes_simple
2
+ # @macro item_action_return_with_attrs_and_id
3
+ # @option attrs [Fixnum] :id_in_project uniq issue identeficator in project
4
+
5
+ # @!macro [new] issue_attributes
6
+ # @macro item_action_return
7
+ # @param [Hash] attrs attributes for action
8
+ # @option attrs [String] :project_token (@project_token) token of Project on EasyQA
9
+ # @option attrs [String] :summary issue summary. This options required for create issue
10
+ # @option attrs [Fixnum] :test_object_id test object uniq identefiactor on EasyQA
11
+ # @option attrs [String] :description issue description
12
+ # @option attrs [String] :issue_type Issue type.
13
+ # Can be in 'no_type', 'documentation', 'task', 'feature', 'usability_problem', 'bug', 'crash'
14
+ # @option attrs [String] :priority Issue priority.
15
+ # Can be in 'low', 'medium', 'high', 'critical'
16
+ # @option attrs [Fixnum] :assigner_id Issue assigner uniq identeficator on EasyQA
17
+ # @option attrs [Array<Faraday::UploadIO>] :attachments Array of attachments
18
+ # @see EasyqaApi::TestObject
1
19
  module EasyqaApi
20
+ # The class for representation EasyQA Issue object
2
21
  class Issue < Item
22
+ # @!attribute [rw] id
23
+ # @return [Fixnum] The uniq identeficator issue in EasyQA website
24
+ # @return [String] The uniq identeficator issue in yuor project.
25
+ # In format "pid_your_id_"
26
+ # @!attribute [rw] attributes
27
+ # @return [Hash] attributes item from response body in your requests
28
+ # @!attribute [rw] project_token
29
+ # @return [String] your project token
3
30
  attr_accessor :id, :attributes, :project_token
4
31
 
5
32
  install_class_methods!
6
33
 
34
+ # Retrieve all issues in project
35
+ # @macro project_token_param
36
+ # @macro auth_user_param
37
+ # @return [Array] list of issues on EasyQA website
38
+ # @macro see_default_user
7
39
  def self.all(project_token, user = @@default_user)
8
40
  send_request('issues', :get) do |req|
9
41
  req.params = {
@@ -13,16 +45,21 @@ module EasyqaApi
13
45
  end
14
46
  end
15
47
 
48
+ # Create new issue on EasyQA website.
49
+ # @!macro issue_attributes
16
50
  def create(attrs, user = @@default_user)
17
51
  attrs = { project_token: @project_token }.merge(attrs)
18
52
  @attributes = send_request('projects/issues/create', :post, :multipart) do |req|
19
53
  req.body = {
20
54
  token: attrs[:project_token],
21
- auth_token: user.auth_token,
22
- }.merge(attrs.except(:project_token))
55
+ auth_token: user.auth_token
56
+ }.merge(attrs.except(:project_token, :attachments))
57
+ .merge(retrieve_attachments(attrs[:attachments]))
23
58
  end
24
59
  end
25
60
 
61
+ # Show issue attributes on EasyQA website.
62
+ # @!macro issue_attributes_simple
26
63
  def show(attrs = {}, user = @@default_user)
27
64
  attrs = { id: @id, project_token: @project_token }.merge(attrs)
28
65
  attrs[:id] = "pid#{attrs.delete(:id_in_project)}" if attrs[:id_in_project]
@@ -34,6 +71,10 @@ module EasyqaApi
34
71
  end
35
72
  end
36
73
 
74
+ # Update issue on EasyQA website.
75
+ # @!macro issue_attributes
76
+ # @option attrs [Fixnum] :id_in_project uniq issue identeficator in project
77
+ # @option attrs [Fixnum] :id uniq issue identeficator on EasyQA
37
78
  def update(attrs, user = @@default_user)
38
79
  attrs = { id: @id, project_token: @project_token }.merge(attrs)
39
80
  attrs[:id] = "pid#{attrs.delete(:id_in_project)}" if attrs[:id_in_project]
@@ -45,6 +86,8 @@ module EasyqaApi
45
86
  end
46
87
  end
47
88
 
89
+ # Delete issue on EasyQA website.
90
+ # @!macro issue_attributes_simple
48
91
  def delete(attrs = {}, user = @@default_user)
49
92
  attrs = { id: @id, project_token: @project_token }.merge(attrs)
50
93
  attrs[:id] = "pid#{attrs.delete(:id_in_project)}" if attrs[:id_in_project]
@@ -55,5 +98,14 @@ module EasyqaApi
55
98
  }
56
99
  end
57
100
  end
101
+
102
+ private
103
+
104
+ def retrieve_attachments(attachments)
105
+ iterator = 1
106
+ attachments.each_with_object({}) do |attachment, hash|
107
+ hash["attachment#{iterator += 1}"] = attachment
108
+ end
109
+ end
58
110
  end
59
111
  end
@@ -1,9 +1,19 @@
1
1
  module EasyqaApi
2
+ # Representation Issue attachment on EasyQA
2
3
  class IssueAttachment < Item
4
+ # @macro default_attributes_with_project_token
5
+ # @!attribute [rw] issue_id
6
+ # @return [Fixnum] The uniq identeficator issue in EasyQA website
7
+ # @return [String] The uniq identeficator issue in yuor project.
8
+ # In format "pid_your_id_"
3
9
  attr_accessor :id, :attributes, :project_token, :issue_id
4
10
 
5
11
  install_class_methods! only: [:create, :delete]
6
12
 
13
+ # Create attachment on EasyQA website.
14
+ # @macro item_action_return_with_attrs
15
+ # @option attrs [Fixnum] :issue_id (@id) uniq issue identeficator
16
+ # @option attrs [Fixnum] :issue_id_in_project (@id) uniq issue identeficator in project
7
17
  def create(attrs, user = @@default_user)
8
18
  attrs = { project_token: @project_token, issue_id: @issue_id }.merge(attrs)
9
19
  attrs[:issue_id] = "pid#{attrs.delete(:issue_id_in_project)}" if attrs[:issue_id_in_project]
@@ -15,6 +25,8 @@ module EasyqaApi
15
25
  end
16
26
  end
17
27
 
28
+ # Delete attachment on EasyQA website.
29
+ # @macro item_action_return_with_attrs_and_id
18
30
  def delete(attrs = {}, user = @@default_user)
19
31
  attrs = { id: @id, project_token: @project_token }.merge(attrs)
20
32
  @attributes = send_request("attachments/#{attrs[:id]}", :delete) do |req|
@@ -1,9 +1,26 @@
1
+ # @!macro organization_with_attrs
2
+ # @macro item_action_return
3
+ # @param attrs [Hash] attributes for action
4
+ # @option attrs [String] :title title of organization
5
+ # @option attrs [String] :description description of organization
6
+
7
+ # @!macro organization_without_attrs
8
+ # @macro item_action_return
9
+ # @param id [Fixnum] organization id on EasyQA website
1
10
  module EasyqaApi
11
+ # Organization representation from EasyQA
2
12
  class Organization < Item
3
- attr_accessor :title, :description, :id, :attributes
13
+ # @macro default_attributes
14
+ # @!attribute [rw] title
15
+ # @return [String] Title of organization on EasyQA
16
+ attr_accessor :title, :id, :attributes
4
17
 
5
18
  install_class_methods!
6
19
 
20
+ # Retrieve all organizations from user
21
+ # @macro auth_user_param
22
+ # @return [Array] list of organizations on EasyQA website
23
+ # @macro see_default_user
7
24
  def self.all(user = @@default_user)
8
25
  send_request('organizations', :get) do |req|
9
26
  req.params = {
@@ -12,6 +29,8 @@ module EasyqaApi
12
29
  end
13
30
  end
14
31
 
32
+ # Create organization on EasyQA website
33
+ # @!macro organization_with_attrs
15
34
  def create(attrs, user = @@default_user)
16
35
  @attributes = send_request('organizations', :post) do |req|
17
36
  req.body = {
@@ -21,6 +40,8 @@ module EasyqaApi
21
40
  end
22
41
  end
23
42
 
43
+ # Show a organization on EasyQA website
44
+ # @!macro organization_without_attrs
24
45
  def show(id = @id, user = @@default_user)
25
46
  @attributes = send_request("organizations/#{id}", :get) do |req|
26
47
  req.params = {
@@ -29,6 +50,9 @@ module EasyqaApi
29
50
  end
30
51
  end
31
52
 
53
+ # Update organization on EasyQA website
54
+ # @!macro organization_with_attrs
55
+ # @option attrs [Fixnum] :id (@id) organization id on EasyQA website
32
56
  def update(attrs, user = @@default_user)
33
57
  attrs = { id: @id }.merge(attrs)
34
58
  @attributes = send_request("organizations/#{attrs[:id]}", :put) do |req|
@@ -39,6 +63,8 @@ module EasyqaApi
39
63
  end
40
64
  end
41
65
 
66
+ # Delete organization on EasyQA website
67
+ # @!macro organization_without_attrs
42
68
  def delete(id = @id, user = @@default_user)
43
69
  @attributes = send_request("organizations/#{id}", :delete) do |req|
44
70
  req.params = {
@@ -1,9 +1,25 @@
1
+ # @!macro project_with_attrs
2
+ # @macro item_action_return
3
+ # @param attrs [Hash] attributes for action
4
+ # @option attrs [String] :title title of organization
5
+
6
+ # @!macro project_without_attrs
7
+ # @macro item_action_return
8
+ # @param id [Fixnum] project id on EasyQA website
1
9
  module EasyqaApi
10
+ # Project representation from EasyQA
2
11
  class Project < Item
12
+ # @macro default_attributes
13
+ # @!attribute [rw] title
14
+ # @return [String] Project title on EasyQA website
3
15
  attr_accessor :title, :id, :attributes
4
16
 
5
17
  install_class_methods!
6
18
 
19
+ # Retrieve all projects from user
20
+ # @macro auth_user_param
21
+ # @return [Array] list of projects on EasyQA website
22
+ # @macro see_default_user
7
23
  def self.all(user = @@default_user)
8
24
  send_request('projects', :get) do |req|
9
25
  req.params = {
@@ -12,6 +28,9 @@ module EasyqaApi
12
28
  end
13
29
  end
14
30
 
31
+ # Create project on EasyQA.
32
+ # @macro project_with_attrs
33
+ # @option attrs [String] :organization_id organization id on EasyQA website
15
34
  def create(attrs, user = @@default_user)
16
35
  @attributes = send_request('projects', :post) do |req|
17
36
  req.body = {
@@ -22,6 +41,8 @@ module EasyqaApi
22
41
  end
23
42
  end
24
43
 
44
+ # Show project from EasyQA.
45
+ # @macro project_without_attrs
25
46
  def show(id = @id, user = @@default_user)
26
47
  @attributes = send_request("projects/#{id}", :get) do |req|
27
48
  req.params = {
@@ -30,6 +51,9 @@ module EasyqaApi
30
51
  end
31
52
  end
32
53
 
54
+ # Update project on EasyQA.
55
+ # @macro project_with_attrs
56
+ # @option attrs [String] :id project id on EasyQA website
33
57
  def update(attrs, user = @@default_user)
34
58
  attrs = { id: @id }.merge(attrs)
35
59
  @attributes = send_request("projects/#{attrs[:id]}", :put) do |req|
@@ -40,6 +64,8 @@ module EasyqaApi
40
64
  end
41
65
  end
42
66
 
67
+ # Delete project on EasyQA.
68
+ # @macro project_without_attrs
43
69
  def delete(id = @id, user = @@default_user)
44
70
  @attributes = send_request("projects/#{id}", :delete) do |req|
45
71
  req.params = {
@@ -1,9 +1,28 @@
1
+ # @!macro role_with_attrs
2
+ # @macro item_action_return
3
+ # @param attrs [Hash] action attributes
4
+ # @option attrs [String] :role role name
5
+
6
+ # @!macro role_without_attrs
7
+ # @macro item_action_return
8
+ # @param id [String] role id on EasyQA website
1
9
  module EasyqaApi
10
+ # Role representation from EasyQA website
11
+ # Project role can be 'developer', 'tester', 'viewer' or 'project_manager'
12
+ # Organization role can be 'user' or 'admin'
2
13
  class Role < Item
14
+ # @macro default_attributes
15
+ # @!attribute [rw] role
16
+ # @return [String] Role user in currentproject or organization
3
17
  attr_accessor :role, :id, :attributes
4
18
 
5
19
  install_class_methods!
6
20
 
21
+ # Retrieve all roles from organization
22
+ # @macro auth_user_param
23
+ # @param organization_id [Fixnum] Organization id on EasyQA website
24
+ # @return [Array] list of organization roles on EasyQA website
25
+ # @macro see_default_user
7
26
  def self.all(organization_id, user = @@default_user)
8
27
  send_request("organizations/#{organization_id}/roles", :get) do |req|
9
28
  req.params = {
@@ -12,6 +31,11 @@ module EasyqaApi
12
31
  end
13
32
  end
14
33
 
34
+ # Create role on EasyQA website.
35
+ # @!macro role_with_attrs
36
+ # @option attrs [Fixnum] :organization_id organization id on EasyQA website
37
+ # @option attrs [Fixnum] :user_id user id on EasyQA website.
38
+ # @option attrs [String] :project_token Project token on EasyQA. Add this option if you want create project role
15
39
  def create(attrs, user = @@default_user)
16
40
  @attributes = send_request("organizations/#{attrs[:organization_id]}/roles", :post) do |req|
17
41
  req.body = {
@@ -20,6 +44,8 @@ module EasyqaApi
20
44
  end
21
45
  end
22
46
 
47
+ # Show role from EasyQA website.
48
+ # @macro role_without_attrs
23
49
  def show(id = @id, user = @@default_user)
24
50
  @attributes = send_request("roles/#{id}", :get) do |req|
25
51
  req.params = {
@@ -28,6 +54,9 @@ module EasyqaApi
28
54
  end
29
55
  end
30
56
 
57
+ # Update role on EasyQA website.
58
+ # @macro role_without_attrs
59
+ # @param role [Fixnum] role name on EasyQA website
31
60
  def update(role, id = @id, user = @@default_user)
32
61
  @attributes = send_request("roles/#{id}", :put) do |req|
33
62
  req.body = {
@@ -37,6 +66,8 @@ module EasyqaApi
37
66
  end
38
67
  end
39
68
 
69
+ # Delete role on EasyQA website.
70
+ # @macro role_without_attrs
40
71
  def delete(id = @id, user = @@default_user)
41
72
  @attributes = send_request("roles/#{id}", :delete) do |req|
42
73
  req.params = {
@@ -1,9 +1,26 @@
1
+ # @!macro status_with_attrs
2
+ # @macro item_action_return_with_attrs_and_id
3
+ # @option attrs [String] :name status name
4
+
5
+ # @!macro status_without_attributes
6
+ # @macro item_action_return
7
+ # @param id [Fixnum] status id on EasyQA website
8
+ # @param project_token [Fixnum] project token on EasyQA website
1
9
  module EasyqaApi
10
+ # Status representation on EasyQA website
2
11
  class Status < Item
12
+ # @macro default_attributes_with_project_token
13
+ # @!attribute [rw] name
14
+ # @return [String] Status name on EasyQA
3
15
  attr_accessor :name, :id, :attributes, :project_token
4
16
 
5
17
  install_class_methods!
6
18
 
19
+ # Retrieve all issues in project
20
+ # @macro project_token_param
21
+ # @macro auth_user_param
22
+ # @return [Array] list of statuses on EasyQA website
23
+ # @macro see_default_user
7
24
  def self.all(project_token, user = @@default_user)
8
25
  send_request('statuses', :get) do |req|
9
26
  req.params = {
@@ -13,6 +30,8 @@ module EasyqaApi
13
30
  end
14
31
  end
15
32
 
33
+ # Create status on EasyQA website
34
+ # @macro status_with_attrs
16
35
  def create(attrs, user = @@default_user)
17
36
  attrs = { project_token: @project_token }.merge(attrs)
18
37
  @attributes = send_request('statuses', :post) do |req|
@@ -24,6 +43,8 @@ module EasyqaApi
24
43
  end
25
44
  end
26
45
 
46
+ # Show status from EasyQA website
47
+ # @macro status_without_attributes
27
48
  def show(project_token = @project_token, id = @id, user = @@default_user)
28
49
  @attributes = send_request("statuses/#{id}", :get) do |req|
29
50
  req.params = {
@@ -33,6 +54,9 @@ module EasyqaApi
33
54
  end
34
55
  end
35
56
 
57
+ # Update status on EasyQA website
58
+ # @macro status_with_attrs
59
+ # @option attrs [Fixnum] :id (@id) status id on EasyQA website
36
60
  def update(attrs, user = @@default_user)
37
61
  attrs = { id: @id, project_token: @project_token }.merge(attrs)
38
62
  @attributes = send_request("statuses/#{attrs[:id]}", :put) do |req|
@@ -44,6 +68,8 @@ module EasyqaApi
44
68
  end
45
69
  end
46
70
 
71
+ # Delete status on EasyQA website
72
+ # @macro status_without_attributes
47
73
  def delete(project_token = @project_token, id = @id, user = @@default_user)
48
74
  @attributes = send_request("statuses/#{id}", :delete) do |req|
49
75
  req.params = {
@@ -1,9 +1,37 @@
1
+ # @!macro test_case_with_attrs
2
+ # @macro item_action_return_with_attrs
3
+ # @option attrs [String] :title test case title on EasyQA website
4
+ # @option attrs [String] :pre_steps test case pre steps
5
+ # @option attrs [String] :steps Test Case steps.
6
+ # @option attrs [String] :expected_result Test Case expected result.
7
+ # @option attrs [String] :case_type Type of test case.
8
+ # Can be 'positive', 'negative', 'boundary', 'integration', 'ui' or 'localization'
9
+ # @see EasyqaApi::TestModule
10
+
11
+ # @!macro test_case_without_attrs
12
+ # @macro item_action_return
13
+ # @macro project_token_param
14
+ # @!macro id_param
1
15
  module EasyqaApi
16
+ # Test case representation from EasyQA website
2
17
  class TestCase < Item
18
+ # @macro default_attributes_with_project_token
19
+ # @!attribute [rw] title
20
+ # @return [String] Test case title on EasyQA
21
+ # @!attribute [rw] module_id
22
+ # @return [String] Test module id on EasyQA
3
23
  attr_accessor :title, :id, :attributes, :project_token, :module_id
4
24
 
5
25
  install_class_methods!
6
26
 
27
+ # List of all test cases
28
+ # @param attrs [Hash] attributes for action
29
+ # @option attrs [String] :project_token project_token on EasyQA website
30
+ # @option attrs [String] :parent_name Can be "test_plan" or "test_module".
31
+ # @option attrs [Fixnum] :parent_id Id of test plan and test module according
32
+ # @macro auth_user_param
33
+ # @return [Array] list of test_cases on EasyQA website
34
+ # @macro see_default_user
7
35
  def self.all(attrs, user = @@default_user)
8
36
  send_request("#{attrs[:parent_name]}/#{attrs[:parent_id]}/test_cases", :get) do |req|
9
37
  req.params = {
@@ -13,6 +41,9 @@ module EasyqaApi
13
41
  end
14
42
  end
15
43
 
44
+ # Create test case on EasyQA website.
45
+ # @macro test_case_with_attrs
46
+ # @option attrs [Fixnum] :test_module_id Test module id
16
47
  def create(attrs, user = @@default_user)
17
48
  attrs = { project_token: @project_token, module_id: @module_id }.merge(attrs)
18
49
  @attributes = send_request("test_modules/#{attrs[:module_id]}/test_cases", :post) do |req|
@@ -24,6 +55,8 @@ module EasyqaApi
24
55
  end
25
56
  end
26
57
 
58
+ # Show Test Case from EasyQA website.
59
+ # @!macro test_case_without_attrs
27
60
  def show(project_token = @project_token, id = @id, user = @@default_user)
28
61
  @attributes = send_request("test_cases/#{id}", :get) do |req|
29
62
  req.params = {
@@ -33,6 +66,9 @@ module EasyqaApi
33
66
  end
34
67
  end
35
68
 
69
+ # Update Test Case on EasyQA website.
70
+ # @!macro test_case_with_attrs
71
+ # @option attrs [Fixnum] :id (@id) item id
36
72
  def update(attrs, user = @@default_user)
37
73
  attrs = { id: @id, project_token: @project_token }.merge(attrs)
38
74
  @attributes = send_request("test_cases/#{attrs[:id]}", :put) do |req|
@@ -44,6 +80,8 @@ module EasyqaApi
44
80
  end
45
81
  end
46
82
 
83
+ # Delete Test Case on EasyQA website.
84
+ # @!macro test_case_without_attrs
47
85
  def delete(project_token = @project_token, id = @id, user = @@default_user)
48
86
  @attributes = send_request("test_cases/#{id}", :delete) do |req|
49
87
  req.params = {
@@ -1,9 +1,33 @@
1
+ # @!macro test_module_with_attrs
2
+ # @macro item_action_return_with_attrs
3
+ # @option attrs [String] :title test module title on EasyQA website
4
+ # @option attrs [String] :description test module description
5
+ # @option attrs [Fixnum] :parent_id id of parent test module.
6
+ # If you give this parameter, this test module will be nested in parent test module.
7
+ # @see EasyqaApi::TestPlan
8
+
9
+ # @!macro test_module_without_attrs
10
+ # @macro item_action_return
11
+ # @macro project_token_param
12
+ # @!macro id_param
1
13
  module EasyqaApi
14
+ # Test module representation from EasyQA website
2
15
  class TestModule < Item
16
+ # @macro default_attributes_with_project_token
17
+ # @!attribute [rw] title
18
+ # @return [String] Test module title on EasyQA
19
+ # @!attribute [rw] test_plan_id
20
+ # @return [String] Test plan id on EasyQA
3
21
  attr_accessor :title, :id, :attributes, :project_token, :test_plan_id
4
22
 
5
23
  install_class_methods!
6
24
 
25
+ # List of all test modules
26
+ # @param test_plan_id [Fixnum] Test plan id on EasyQA website
27
+ # @macro project_token_param
28
+ # @macro auth_user_param
29
+ # @return [Array] list of test modules on EasyQA website
30
+ # @macro see_default_user
7
31
  def self.all(project_token, test_plan_id, user = @@default_user)
8
32
  send_request("test_plans/#{test_plan_id}/test_modules", :get) do |req|
9
33
  req.params = {
@@ -13,6 +37,9 @@ module EasyqaApi
13
37
  end
14
38
  end
15
39
 
40
+ # Create test module on EasyQA website.
41
+ # @macro test_module_with_attrs
42
+ # @option attrs [Fixnum] :test_plan_id (@test_plan_id) Test plan id
16
43
  def create(attrs, user = @@default_user)
17
44
  attrs = { project_token: @project_token, test_plan_id: @test_plan_id }.merge(attrs)
18
45
  @attributes = send_request("test_plans/#{attrs[:test_plan_id]}/test_modules", :post) do |req|
@@ -24,6 +51,8 @@ module EasyqaApi
24
51
  end
25
52
  end
26
53
 
54
+ # Show Test Case from EasyQA website.
55
+ # @!macro test_module_without_attrs
27
56
  def show(project_token = @project_token, id = @id, user = @@default_user)
28
57
  @attributes = send_request("test_modules/#{id}", :get) do |req|
29
58
  req.params = {
@@ -33,6 +62,9 @@ module EasyqaApi
33
62
  end
34
63
  end
35
64
 
65
+ # Update Test Case on EasyQA website.
66
+ # @!macro test_module_with_attrs
67
+ # @option attrs [Fixnum] :id (@id) item id
36
68
  def update(attrs, user = @@default_user)
37
69
  attrs = { id: @id, project_token: @project_token }.merge(attrs)
38
70
  @attributes = send_request("test_modules/#{attrs[:id]}", :put) do |req|
@@ -44,6 +76,8 @@ module EasyqaApi
44
76
  end
45
77
  end
46
78
 
79
+ # Delete Test Case on EasyQA website.
80
+ # @!macro test_module_without_attrs
47
81
  def delete(project_token = @project_token, id = @id, user = @@default_user)
48
82
  @attributes = send_request("test_modules/#{id}", :delete) do |req|
49
83
  req.params = {
@@ -1,9 +1,20 @@
1
+ # @!macro test_object_params
2
+ # @macro item_action_return
3
+ # @macro project_token_param
4
+ # @macro id_param
1
5
  module EasyqaApi
6
+ # Test object representation from EasyQA website
2
7
  class TestObject < Item
8
+ # @macro default_attributes_with_project_token
3
9
  attr_accessor :id, :attributes, :project_token
4
10
 
5
11
  install_class_methods! except: [:update]
6
12
 
13
+ # List of all test objects
14
+ # @macro auth_user_param
15
+ # @macro project_token_param
16
+ # @return [Array] list of test objects on EasyQA website
17
+ # @macro see_default_user
7
18
  def self.all(project_token, user = @@default_user)
8
19
  send_request('test_objects', :get) do |req|
9
20
  req.params = {
@@ -13,6 +24,10 @@ module EasyqaApi
13
24
  end
14
25
  end
15
26
 
27
+ # Create test object on EasyQA website
28
+ # @macro item_action_return_with_attrs
29
+ # @option attrs [String] :link link to your webiste for web object on EasyQA website
30
+ # @option attrs [Faraday::UploadIO] :file your apk or ipa file
16
31
  def create(attrs, user = @@default_user)
17
32
  attrs = { project_token: @project_token }.merge(attrs)
18
33
  @attributes = send_request('test_objects', :post, :multipart) do |req|
@@ -23,6 +38,8 @@ module EasyqaApi
23
38
  end
24
39
  end
25
40
 
41
+ # Show test object from EasyQA website
42
+ # @macro test_object_params
26
43
  def show(project_token = @project_token, id = @id, user = @@default_user)
27
44
  @attributes = send_request("test_objects/#{id}", :get) do |req|
28
45
  req.params = {
@@ -32,6 +49,8 @@ module EasyqaApi
32
49
  end
33
50
  end
34
51
 
52
+ # Delete test object on EasyQA website
53
+ # @macro test_object_params
35
54
  def delete(project_token = @project_token, id = @id, user = @@default_user)
36
55
  @attributes = send_request("test_objects/#{id}", :delete) do |req|
37
56
  req.params = {
@@ -1,9 +1,27 @@
1
+ # @!macro test_plan_with_attrs
2
+ # @macro item_action_return_with_attrs
3
+ # @option attrs [String] :title test plan title on EasyQA website
4
+ # @option attrs [String] :description test case pre steps
5
+
6
+ # @!macro test_plan_without_attrs
7
+ # @macro item_action_return
8
+ # @macro project_token_param
9
+ # @macro id_param
1
10
  module EasyqaApi
11
+ # Test plan representation from EasyQA website
2
12
  class TestPlan < Item
13
+ # @macro default_attributes_with_project_token
14
+ # @!attribute [rw] title
15
+ # @return [String] Test plan title on EasyQA
3
16
  attr_accessor :title, :id, :attributes, :project_token
4
17
 
5
18
  install_class_methods!
6
19
 
20
+ # List of all test plans in project
21
+ # @macro auth_user_param
22
+ # @macro project_token_param
23
+ # @return [Array] list of test plans on EasyQA website
24
+ # @macro see_default_user
7
25
  def self.all(project_token, user = @@default_user)
8
26
  send_request('test_plans', :get) do |req|
9
27
  req.params = {
@@ -13,6 +31,8 @@ module EasyqaApi
13
31
  end
14
32
  end
15
33
 
34
+ # Create test plan on EasyQA website.
35
+ # @macro test_plan_with_attrs
16
36
  def create(attrs, user = @@default_user)
17
37
  attrs = { project_token: @project_token }.merge(attrs)
18
38
  @attributes = send_request('test_plans', :post) do |req|
@@ -24,6 +44,8 @@ module EasyqaApi
24
44
  end
25
45
  end
26
46
 
47
+ # Show test plan from EasyQA website.
48
+ # @macro test_plan_without_attrs
27
49
  def show(project_token = @project_token, id = @id, user = @@default_user)
28
50
  @attributes = send_request("test_plans/#{id}", :get) do |req|
29
51
  req.params = {
@@ -33,6 +55,9 @@ module EasyqaApi
33
55
  end
34
56
  end
35
57
 
58
+ # Update test plan on EasyQA website.
59
+ # @macro test_plan_with_attrs
60
+ # @option attrs [Fixnum] :id (@id) test plan id on EasyQA website
36
61
  def update(attrs, user = @@default_user)
37
62
  attrs = { id: @id, project_token: @project_token }.merge(attrs)
38
63
  @attributes = send_request("test_plans/#{attrs[:id]}", :put) do |req|
@@ -44,6 +69,8 @@ module EasyqaApi
44
69
  end
45
70
  end
46
71
 
72
+ # Delete test plan on EasyQA website.
73
+ # @macro test_plan_without_attrs
47
74
  def delete(project_token = @project_token, id = @id, user = @@default_user)
48
75
  @attributes = send_request("test_plans/#{id}", :delete) do |req|
49
76
  req.params = {
@@ -1,9 +1,36 @@
1
+ # @!macro test_run_with_attrs
2
+ # @macro item_action_return
3
+ # @param [Hash] attrs
4
+ # * :project_token (String) [@project_token] Project token on EasyQA
5
+ # * :title (String) test run title on EasyQA website
6
+ # * :assigner_id (Fixnum) test run assigner id on EasyQA website
7
+ # * :test_plan_id (Fixnum) test plan id on EasyQA website
8
+ # * :description (String) test run description on EasyQA website
9
+ # * :test_run_result_attributes (Array<Hash>) attributes of test run results.
10
+ # * :test_plan_id (Fixnum) id of test plan
11
+ # * :test_case_id (Fixnum) test case id
12
+ # * :id (Fixnum) test run result id
13
+ # * :_destroy (TrueClass, FalseClass) if you set this
14
+ # attribute true with attribute id, this test run result will be deleted
15
+ # @note If you add test plan id to tes_run_result_attributes all test cases from this test plan
16
+ # has been included to your test run
17
+
18
+ # @!macro test_run_without_attrs
19
+ # @macro item_action_return
20
+ # @macro project_token_param
21
+ # @macro id_param
1
22
  module EasyqaApi
23
+ # Test Run representation from EasyQA website
2
24
  class TestRun < Item
3
25
  attr_accessor :title, :id, :attributes, :project_token
4
26
 
5
27
  install_class_methods!
6
28
 
29
+ # List of all test runs in project
30
+ # @macro auth_user_param
31
+ # @macro project_token_param
32
+ # @return [Array] list of test runs on EasyQA website
33
+ # @macro see_default_user
7
34
  def self.all(project_token, user = @@default_user)
8
35
  send_request('test_runs', :get) do |req|
9
36
  req.params = {
@@ -13,6 +40,8 @@ module EasyqaApi
13
40
  end
14
41
  end
15
42
 
43
+ # Create test run on EasyQA website.
44
+ # @macro test_run_with_attrs
16
45
  def create(attrs, user = @@default_user)
17
46
  attrs = { project_token: @project_token }.merge(attrs)
18
47
  @attributes = send_request('test_runs', :post) do |req|
@@ -24,6 +53,8 @@ module EasyqaApi
24
53
  end
25
54
  end
26
55
 
56
+ # Show test run from EasyQA website.
57
+ # @!macro test_run_without_attrs
27
58
  def show(project_token = @project_token, id = @id, user = @@default_user)
28
59
  @attributes = send_request("test_runs/#{id}", :get) do |req|
29
60
  req.params = {
@@ -33,6 +64,9 @@ module EasyqaApi
33
64
  end
34
65
  end
35
66
 
67
+ # Update test run on EasyQA website.
68
+ # @macro test_run_with_attrs
69
+ # @option attrs [Fixnum] :id (@id) test run id
36
70
  def update(attrs, user = @@default_user)
37
71
  attrs = { id: @id, project_token: @project_token }.merge(attrs)
38
72
  @attributes = send_request("test_runs/#{attrs[:id]}", :put) do |req|
@@ -44,6 +78,8 @@ module EasyqaApi
44
78
  end
45
79
  end
46
80
 
81
+ # Delete test run on EasyQA website.
82
+ # @!macro test_run_without_attrs
47
83
  def delete(project_token = @project_token, id = @id, user = @@default_user)
48
84
  @attributes = send_request("test_runs/#{id}", :delete) do |req|
49
85
  req.params = {
@@ -1,9 +1,23 @@
1
+ # @!macro test_run_results_without_attrs
2
+ # @macro item_action_return
3
+ # @macro project_token_param
4
+ # @macro id_param
1
5
  module EasyqaApi
6
+ # Test run result representation from EasyQA website
2
7
  class TestRunResult < Item
8
+ # @macro default_attributes_with_project_token
9
+ # @!attribute [rw] test_run_id
10
+ # @return [String] Test run id on EasyQA
3
11
  attr_accessor :id, :attributes, :project_token, :test_run_id
4
12
 
5
13
  install_class_methods!
6
14
 
15
+ # List of all test run results in test run
16
+ # @macro auth_user_param
17
+ # @macro project_token_param
18
+ # @param test_run_id [Fixnum] test run id on EasyQA website
19
+ # @return [Array] list of test run results
20
+ # @macro see_default_user
7
21
  def self.all(project_token, test_run_id, user = @@default_user)
8
22
  send_request("test_runs/#{test_run_id}/test_run_results", :get) do |req|
9
23
  req.params = {
@@ -13,17 +27,8 @@ module EasyqaApi
13
27
  end
14
28
  end
15
29
 
16
- def create(attrs, user = @@default_user)
17
- attrs = { project_token: @project_token, test_run_id: @test_run_id }.merge(attrs)
18
- @attributes = send_request("test_runs/#{attrs[:test_run_id]}/test_run_results", :post) do |req|
19
- req.body = {
20
- test_run_result: attrs.except(:project_token, :test_run_id),
21
- token: attrs[:project_token],
22
- auth_token: user.auth_token
23
- }
24
- end
25
- end
26
-
30
+ # Show test run result from EasyQA website
31
+ # @macro test_run_results_without_attrs
27
32
  def show(project_token = @project_token, id = @id, user = @@default_user)
28
33
  @attributes = send_request("test_run_results/#{id}", :get) do |req|
29
34
  req.params = {
@@ -33,6 +38,10 @@ module EasyqaApi
33
38
  end
34
39
  end
35
40
 
41
+ # @macro item_action_return_with_attrs_and_id
42
+ # @option attrs [Fixnum] :test_case_id test case id on EasyQA website
43
+ # @option attrs [String] :result_status test run result status
44
+ # @note test_run_result_status can be 'pass', 'block', 'untested' or 'fail'
36
45
  def update(attrs, user = @@default_user)
37
46
  attrs = { id: @id, project_token: @project_token }.merge(attrs)
38
47
  @attributes = send_request("test_run_results/#{attrs[:id]}", :put) do |req|
@@ -44,6 +53,8 @@ module EasyqaApi
44
53
  end
45
54
  end
46
55
 
56
+ # Delete test run result on EasyQA website
57
+ # @macro test_run_results_without_attrs
47
58
  def delete(project_token = @project_token, id = @id, user = @@default_user)
48
59
  @attributes = send_request("test_run_results/#{id}", :delete) do |req|
49
60
  req.params = {
@@ -1,7 +1,18 @@
1
1
  module EasyqaApi
2
+ # User representation from EasyQA website
2
3
  class User < Item
4
+ # @!attribute [rw] auth_token
5
+ # @return [String] user auth_token on EasyQA website
6
+ # @!attribute [rw] name
7
+ # @return [String] user name on EasyQA website
3
8
  attr_accessor :auth_token, :name
4
9
 
10
+ # @param attrs [Hash] param for action
11
+ # @option attrs [String] :email user email
12
+ # @option attrs [String] :password user password
13
+ # @note If you give user email and password you will be already signed on EasyQA.
14
+ # @see auth_token
15
+ # @see sign_in
5
16
  def initialize(attrs = {})
6
17
  super
7
18
  install_variables!(
@@ -9,6 +20,11 @@ module EasyqaApi
9
20
  )
10
21
  end
11
22
 
23
+ # Sign in user on EasyQA website
24
+ # @param email [String] Email user on EasyQA
25
+ # @param password [String] password user on EasyQA
26
+ # @return [Hash] user attributes on EasyQA webiste
27
+ # @see auth_token
12
28
  def sign_in(email, password)
13
29
  send_request('sign_in', :post) do |req|
14
30
  req.body = {
@@ -20,12 +36,18 @@ module EasyqaApi
20
36
  end
21
37
  end
22
38
 
39
+ # Sign out user on EasyQA website
40
+ # @return [Hash] user attributes on EasyQA webiste
41
+ # @see auth_token
23
42
  def sign_out
24
43
  send_request('sign_out', :delete) do |req|
25
- req.body = { auth_token: auth_token || @auth_token }
44
+ req.body = { auth_token: @auth_token }
26
45
  end
27
46
  end
28
47
 
48
+ # Set default user on EasyqaApi
49
+ # @return [EasyqaApi::User] current user
50
+ # @see EasyqaApi::Item::@@default_user
29
51
  def set_default!
30
52
  @@default_user = self
31
53
  end
@@ -1,3 +1,4 @@
1
1
  module EasyqaApi
2
- VERSION = '0.0.2'
2
+ # EasyqaApi gem version
3
+ VERSION = '0.0.3'
3
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easyqa_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thinkmobiles
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-07 00:00:00.000000000 Z
11
+ date: 2017-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler