Class: EasyqaApi::Role

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

Overview

Role representation from EasyQA website

Project role can be 'developer', 'tester', 'viewer' or 'project_manager'
Organization role can be 'user' or 'admin'

Constant Summary

Constants inherited from Item

Item::CONNECTION

Constants included from ClassMethodsSettable

ClassMethodsSettable::METHODS

Instance Attribute Summary collapse

Class Method 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



17
# File 'lib/easyqa_api/items/role.rb', line 17

attr_accessor :role, :id, :attributes

#idFixnum

Returns The uniq identeficator item on EasyQA website.

Returns:

  • (Fixnum)

    The uniq identeficator item on EasyQA website



17
# File 'lib/easyqa_api/items/role.rb', line 17

attr_accessor :role, :id, :attributes

#roleString

Returns Role user in currentproject or organization.

Returns:

  • (String)

    Role user in currentproject or organization



17
18
19
# File 'lib/easyqa_api/items/role.rb', line 17

def role
  @role
end

Class Method Details

.all(organization_id, user = @@default_user) ⇒ Array

Retrieve all roles from organization

Parameters:

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

    authenticated user in EasyQA

  • organization_id (Fixnum)

    Organization id on EasyQA website

Returns:

  • (Array)

    list of organization roles on EasyQA website

See Also:



26
27
28
29
30
31
32
# File 'lib/easyqa_api/items/role.rb', line 26

def self.all(organization_id, user = @@default_user)
  send_request("organizations/#{organization_id}/roles", :get) do |req|
    req.params = {
      auth_token: user.auth_token
    }
  end
end

Instance Method Details

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

Create role on EasyQA website. Have a class method analog

Parameters:

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

    authenticated user in EasyQA

  • attrs (Hash)

    action attributes

Options Hash (attrs):

  • :role (String)

    role name

  • :organization_id (Fixnum)

    organization id on EasyQA website

  • :user_id (Fixnum)

    user id on EasyQA website.

  • :project_token (String)

    Project token on EasyQA. Add this option if you want create project role

Returns:

  • (Hash)

    item attribtues on EasyQA website

See Also:



39
40
41
42
43
44
45
# File 'lib/easyqa_api/items/role.rb', line 39

def create(attrs, user = @@default_user)
  @attributes = send_request("organizations/#{attrs[:organization_id]}/roles", :post) do |req|
    req.body = {
      auth_token: user.auth_token
    }.merge(attrs.except(:organization_id))
  end
end

#delete(id = @id, user = @@default_user) ⇒ Hash

Delete role on EasyQA website. Have a class method analog

Parameters:

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

    authenticated user in EasyQA

  • id (String) (defaults to: @id)

    role id on EasyQA website

Returns:

  • (Hash)

    item attribtues on EasyQA website

See Also:



71
72
73
74
75
76
77
# File 'lib/easyqa_api/items/role.rb', line 71

def delete(id = @id, user = @@default_user)
  @attributes = send_request("roles/#{id}", :delete) do |req|
    req.params = {
      auth_token: user.auth_token
    }
  end
end

#show(id = @id, user = @@default_user) ⇒ Hash

Show role from EasyQA website. Have a class method analog

Parameters:

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

    authenticated user in EasyQA

  • id (String) (defaults to: @id)

    role id on EasyQA website

Returns:

  • (Hash)

    item attribtues on EasyQA website

See Also:



49
50
51
52
53
54
55
# File 'lib/easyqa_api/items/role.rb', line 49

def show(id = @id, user = @@default_user)
  @attributes = send_request("roles/#{id}", :get) do |req|
    req.params = {
      auth_token: user.auth_token
    }
  end
end

#update(role, id = @id, user = @@default_user) ⇒ Hash

Update role on EasyQA website. Have a class method analog

Parameters:

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

    authenticated user in EasyQA

  • id (String) (defaults to: @id)

    role id on EasyQA website

  • role (Fixnum)

    role name on EasyQA website

Returns:

  • (Hash)

    item attribtues on EasyQA website

See Also:



60
61
62
63
64
65
66
67
# File 'lib/easyqa_api/items/role.rb', line 60

def update(role, id = @id, user = @@default_user)
  @attributes = send_request("roles/#{id}", :put) do |req|
    req.body = {
      role: role,
      auth_token: user.auth_token
    }
  end
end