Module: Virtuous::Client::Project

Included in:
Virtuous::Client
Defined in:
lib/virtuous/client/project.rb

Instance Method Summary collapse

Instance Method Details

#project_query_optionsHash

Queries a list of available project query options.

Returns:

  • (Hash)

    A list of available project query options.



7
8
9
# File 'lib/virtuous/client/project.rb', line 7

def project_query_options
  parse(get('api/Project/QueryOptions'))
end

#query_projects(**options) ⇒ Hash

Queries projects.

Examples:

client.query_projects(
  take: 5, skip: 0, sort_by: 'Id',
  conditions: [{ parameter: 'Project Code', operator: 'Is', value: 102 }]
)

Output

{ list: [...], total: n }

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • :take (Integer)

    The maximum amount of projects to query. Default: 10. Max is 1000.

  • :skip (Integer)

    The number of projects to skip. Default: 0.

  • :sort_by (String)

    The value to sort records by.

  • :descending (Boolean)

    If true the records will be sorted in descending order.

  • :conditions (Array)

    An array of conditions to filter the project. Use #project_query_options to see a full list of available conditions.

Returns:

  • (Hash)

    A hash with a list and the total amount of projects that satisfy the conditions.



35
36
37
38
39
40
41
# File 'lib/virtuous/client/project.rb', line 35

def query_projects(**options)
  uri = URI('api/Project/Query')
  query_params = options.slice(:take, :skip)
  uri.query = URI.encode_www_form(query_params) unless query_params.empty?

  parse(post(uri, format(query_projects_body(options))))
end