Class: EasyqaApi::Item
- Inherits:
-
Object
- Object
- EasyqaApi::Item
- Extended by:
- ClassMethodsSettable
- Defined in:
- lib/easyqa_api/item.rb
Overview
The class for representation EasyQA objects
Direct Known Subclasses
Issue, IssueAttachment, Organization, Project, Role, Status, TestCase, TestModule, TestObject, TestPlan, TestRun, TestRunResult, User
Constant Summary collapse
- CONNECTION =
constant for Faradat connection by content type
{ json: { instance: -> { json_connection }, content_type: 'application/json' }, multipart: { instance: -> { multipart_connection }, content_type: 'multipart/form-data' } }.freeze
- @@default_user =
Deafult user in EasyqaApi Items.
If you set this attributes you can use any methods without set user in all methods
nil
Constants included from ClassMethodsSettable
Class Method Summary collapse
-
.json_connection ⇒ Faraday::Connection
retrieve or create Faraday json connection.
-
.multipart_connection ⇒ Faraday::Connection
retrieve or create Faraday multipart connection.
-
.operation_status(response) ⇒ Hash
Processing response.
-
.send_request(url, html_method, type = :json) { ... } ⇒ Hash
Send request to EasyQA api within default configuration.
Instance Method Summary collapse
-
#initialize(*_args) ⇒ Item
constructor
A new instance of Item.
-
#install_variables!(arguments) ⇒ Object
Install variables for Item instance if key in attribute has a valid setter in instance.
Methods included from ClassMethodsSettable
Constructor Details
#initialize(*_args) ⇒ Item
Returns a new instance of Item.
127 128 |
# File 'lib/easyqa_api/item.rb', line 127 def initialize(*_args) end |
Class Method Details
.json_connection ⇒ Faraday::Connection
retrieve or create Faraday json connection
68 69 70 71 72 73 74 |
# File 'lib/easyqa_api/item.rb', line 68 def json_connection @json_connection ||= Faraday.new(url: EasyqaApi.configuration.url) do |faraday| faraday.request :json faraday.response :json faraday.adapter Faraday.default_adapter end end |
.multipart_connection ⇒ Faraday::Connection
retrieve or create Faraday multipart connection
78 79 80 81 82 83 84 |
# File 'lib/easyqa_api/item.rb', line 78 def multipart_connection @multipart_connection ||= Faraday.new(url: EasyqaApi.configuration.url) do |faraday| faraday.request :multipart faraday.response :json faraday.adapter Faraday.default_adapter end end |
.operation_status(response) ⇒ Hash
Processing response
121 122 123 124 |
# File 'lib/easyqa_api/item.rb', line 121 def operation_status(response) EasyqaApi::Exception.check_response_status!(response) response.body end |
.send_request(url, html_method, type = :json) { ... } ⇒ Hash
Send request to EasyQA api within default configuration
106 107 108 109 110 111 112 113 114 |
# File 'lib/easyqa_api/item.rb', line 106 def send_request(url, html_method, type = :json, &block) response = EasyqaApi::Item::CONNECTION[type][:instance].call.send(html_method) do |req| req.url EasyqaApi.configuration.api_path + url req.headers['Content-Type'] = EasyqaApi::Item::CONNECTION[type][:content_type] yield(req) if block end operation_status(response) end |
Instance Method Details
#install_variables!(arguments) ⇒ Object
Install variables for Item instance if key in attribute has a valid setter in instance
132 133 134 135 136 137 138 |
# File 'lib/easyqa_api/item.rb', line 132 def install_variables!(arguments) allowed_methods = retrive_allowed_methods arguments.each do |key, value| method_name = "#{key}=".to_sym send(method_name, value) if allowed_methods.include? method_name end end |