Class: School21::EventsApi

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

Constant Summary collapse

EVENT_TYPES =
%w[ACTIVITY EXAM TEST].freeze

Constants inherited from BaseApi

BaseApi::PLATFORM_AUTH_PARTICIPANT

Instance Method Summary collapse

Methods inherited from BaseApi

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

Constructor Details

This class inherits a constructor from School21::BaseApi

Instance Method Details

#events(from:, to:, options: {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/school21/api/events_api.rb', line 9

def events(from:, to:, options: {})
  path = '/events'
  default_options = {
    limit: 50,
    offset: 0
  }.merge(options).merge(
    from: formatted_date_time(from, :from),
    to: formatted_date_time(to, :to)
  ).compact

  validate_event_type(default_options[:type])

  new_request = request_with_auth_participant(HttpMethod::GET, path, :api_v1)

  default_options.each do |key, value|
    new_request.query_param(new_parameter(value, key:))
  end

  execute_request(new_request)
end