Class: EasyqaApi::Project

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

Overview

Project representation from EasyQA

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



15
# File 'lib/easyqa_api/items/project.rb', line 15

attr_accessor :title, :id, :attributes

#idFixnum

Returns The uniq identeficator item on EasyQA website.

Returns:

  • (Fixnum)

    The uniq identeficator item on EasyQA website



15
# File 'lib/easyqa_api/items/project.rb', line 15

attr_accessor :title, :id, :attributes

#titleString

Returns Project title on EasyQA website.

Returns:

  • (String)

    Project title on EasyQA website



15
16
17
# File 'lib/easyqa_api/items/project.rb', line 15

def title
  @title
end

Class Method Details

.all(user = @@default_user) ⇒ Array

Retrieve all projects from user

Parameters:

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

    authenticated user in EasyQA

Returns:

  • (Array)

    list of projects on EasyQA website

See Also:



23
24
25
26
27
28
29
# File 'lib/easyqa_api/items/project.rb', line 23

def self.all(user = @@default_user)
  send_request('projects', :get) do |req|
    req.params = {
      auth_token: user.auth_token
    }
  end
end

Instance Method Details

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

Create project on EasyQA. 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):

  • :title (String)

    title of organization

  • :organization_id (String)

    organization id on EasyQA website

Returns:

  • (Hash)

    item attribtues on EasyQA website

See Also:



34
35
36
37
38
39
40
41
42
# File 'lib/easyqa_api/items/project.rb', line 34

def create(attrs, user = @@default_user)
  @attributes = send_request('projects', :post) do |req|
    req.body = {
      organization_id: attrs[:organization_id],
      project: attrs.except(:organization_id),
      auth_token: user.auth_token
    }
  end
end

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

Delete project on EasyQA. Have a class method analog

Parameters:

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

    authenticated user in EasyQA

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

    project id on EasyQA website

Returns:

  • (Hash)

    item attribtues on EasyQA website

See Also:



69
70
71
72
73
74
75
# File 'lib/easyqa_api/items/project.rb', line 69

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

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

Show project from EasyQA. Have a class method analog

Parameters:

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

    authenticated user in EasyQA

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

    project id on EasyQA website

Returns:

  • (Hash)

    item attribtues on EasyQA website

See Also:



46
47
48
49
50
51
52
# File 'lib/easyqa_api/items/project.rb', line 46

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

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

Update project on EasyQA. 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):

  • :title (String)

    title of organization

  • :id (String)

    project id on EasyQA website

Returns:

  • (Hash)

    item attribtues on EasyQA website

See Also:



57
58
59
60
61
62
63
64
65
# File 'lib/easyqa_api/items/project.rb', line 57

def update(attrs, user = @@default_user)
  attrs = { id: @id }.merge(attrs)
  @attributes = send_request("projects/#{attrs[:id]}", :put) do |req|
    req.body = {
      project: attrs.except(:id),
      auth_token: user.auth_token
    }
  end
end