Class: PlatformSdk::Central::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/platform_sdk/central/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_url, access_token, conn: nil) ⇒ Client

Returns a new instance of Client.



6
7
8
9
10
# File 'lib/platform_sdk/central/client.rb', line 6

def initialize(base_url, access_token, conn: nil)
  @access_token = access_token
  @base_url = base_url
  @conn = conn || build_connection
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



4
5
6
# File 'lib/platform_sdk/central/client.rb', line 4

def access_token
  @access_token
end

#base_urlObject (readonly)

Returns the value of attribute base_url.



4
5
6
# File 'lib/platform_sdk/central/client.rb', line 4

def base_url
  @base_url
end

#connObject (readonly)

Returns the value of attribute conn.



4
5
6
# File 'lib/platform_sdk/central/client.rb', line 4

def conn
  @conn
end

Instance Method Details

#create_message(message_params: {}) ⇒ Object



29
30
31
32
33
# File 'lib/platform_sdk/central/client.rb', line 29

def create_message(message_params: {})
  resource_path = '/api/messages'
  response = post(resource_path, message_params)
  response.body
end

#notifications(**notification) ⇒ Object



42
43
44
45
46
# File 'lib/platform_sdk/central/client.rb', line 42

def notifications(**notification)
  resource_path = '/api/notifications'
  response = post(resource_path, notification)
  response.body
end

#orgs(roster_id: nil) ⇒ Object



35
36
37
38
39
40
# File 'lib/platform_sdk/central/client.rb', line 35

def orgs(roster_id: nil)
  resource_path = '/api/orgs'
  resource_path += "?roster_id=#{roster_id}" if roster_id
  response = get(resource_path)
  response.body
end

#teacher_enrollments(external_course_id = nil, partner_name = nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/platform_sdk/central/client.rb', line 18

def teacher_enrollments(external_course_id = nil, partner_name = nil)
  resource_path = '/api/teacher_enrollments'

  if external_course_id.present? && partner_name.present?
    resource_path += "?external_course_id=#{external_course_id}&partner_name=#{partner_name}"
  end

  response = get(resource_path)
  response.body
end

#user(uid) ⇒ Object



12
13
14
15
16
# File 'lib/platform_sdk/central/client.rb', line 12

def user(uid)
  resource_path = "/api/users/#{uid}"
  response = get(resource_path)
  response.body
end