Class: EasyqaApi::IssueAttachment

Inherits:
Item
  • Object
show all
Defined in:
lib/easyqa_api/items/issue_attachment.rb

Overview

Representation Issue attachment on EasyQA

Constant Summary

Constants inherited from Item

EasyqaApi::Item::CONNECTION

Constants included from ClassMethodsSettable

ClassMethodsSettable::METHODS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Item

#initialize, #install_variables!, json_connection, multipart_connection, operation_status, send_request

Methods included from ClassMethodsSettable

#install_class_methods!

Constructor Details

This class inherits a constructor from EasyqaApi::Item

Instance Attribute Details

#attributesHash

Returns item attributes from response body in your requests.

Returns:

  • (Hash)

    item attributes from response body in your requests



9
# File 'lib/easyqa_api/items/issue_attachment.rb', line 9

attr_accessor :id, :attributes, :project_token, :issue_id

#idFixnum

Returns The uniq identeficator item on EasyQA website.

Returns:

  • (Fixnum)

    The uniq identeficator item on EasyQA website



9
10
11
# File 'lib/easyqa_api/items/issue_attachment.rb', line 9

def id
  @id
end

#issue_idFixnum, String

Returns:

  • (Fixnum)

    The uniq identeficator issue in EasyQA website

  • (String)

    The uniq identeficator issue in yuor project. In format “pid_your_id_”



9
# File 'lib/easyqa_api/items/issue_attachment.rb', line 9

attr_accessor :id, :attributes, :project_token, :issue_id

#project_tokenString

Returns your project token.

Returns:

  • (String)

    your project token



9
# File 'lib/easyqa_api/items/issue_attachment.rb', line 9

attr_accessor :id, :attributes, :project_token, :issue_id

Instance Method Details

#create(attrs, user = @@default_user) ⇒ Hash

Create attachment on EasyQA website. Have a class method analog

Parameters:

  • user (Easyqapi::User) (defaults to: @@default_user)

    authenticated user in EasyQA

  • attrs (Hash)

    attributes for action

Options Hash (attrs):

  • :project_token (String) — default: @project_token

    Project token on EasyQA

  • :issue_id (Fixnum) — default: @id

    uniq issue identeficator

  • :issue_id_in_project (Fixnum) — default: @id

    uniq issue identeficator in project

Returns:

  • (Hash)

    item attribtues on EasyQA website

See Also:



17
18
19
20
21
22
23
24
25
26
# File 'lib/easyqa_api/items/issue_attachment.rb', line 17

def create(attrs, user = @@default_user)
  attrs = { project_token: @project_token, issue_id: @issue_id }.merge(attrs)
  attrs[:issue_id] = "pid#{attrs.delete(:issue_id_in_project)}" if attrs[:issue_id_in_project]
  @attributes = send_request("issues/#{attrs[:issue_id]}/attachments", :post, :multipart) do |req|
    req.body = {
      token: attrs[:project_token],
      auth_token: user.auth_token
    }.merge(attrs.except(:project_token))
  end
end

#delete(attrs = {}, user = @@default_user) ⇒ Hash

Delete attachment on EasyQA website. Have a class method analog

Parameters:

  • user (Easyqapi::User) (defaults to: @@default_user)

    authenticated user in EasyQA

  • attrs (Hash) (defaults to: {})

    attributes for action

Options Hash (attrs):

  • :project_token (String) — default: @project_token

    Project token on EasyQA

  • :id (Fixnum) — default: @id

    uniq item identeficator

Returns:

  • (Hash)

    item attribtues on EasyQA website

See Also:



30
31
32
33
34
35
36
37
38
# File 'lib/easyqa_api/items/issue_attachment.rb', line 30

def delete(attrs = {}, user = @@default_user)
  attrs = { id: @id, project_token: @project_token }.merge(attrs)
  @attributes = send_request("attachments/#{attrs[:id]}", :delete) do |req|
    req.params = {
      token: attrs[:project_token],
      auth_token: user.auth_token
    }
  end
end