Class: School21::ProjectsApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/school21/api/projects_api.rb

Constant Summary

Constants inherited from BaseApi

BaseApi::SINGLE_AUTH_PARTICIPANT

Instance Method Summary collapse

Methods inherited from BaseApi

base_uri, #initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, response_convertor

Constructor Details

This class inherits a constructor from School21::BaseApi

Instance Method Details

#projects(project_id) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/school21/api/projects_api.rb', line 5

def projects(project_id)
  path = "/projects/#{project_id}"
  new_request = new_request_builder(HttpMethod::GET, path, :api_v1)
                .auth(CoreLibrary::Single.new(SINGLE_AUTH_PARTICIPANT))

  new_api_call_builder
    .request(new_request)
    .response(new_response_handler)
    .execute
end

#projects_participants(project_id, options: {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/school21/api/projects_api.rb', line 16

def projects_participants(project_id, options: {})
  path = "/projects/#{project_id}/participants"
  default_options = { limit: 1000, offset: 0 }.merge(options)

  parameters = default_options.map do |key, value|
    new_parameter(value, key:)
  end

  new_request = new_request_builder(HttpMethod::GET, path, :api_v1)
                .auth(CoreLibrary::Single.new(SINGLE_AUTH_PARTICIPANT))

  parameters.each do |parameter|
    new_request.query_param(parameter)
  end

  new_api_call_builder
    .request(new_request)
    .response(new_response_handler)
    .execute
end