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



25
26
27
28
29
# File 'lib/platform_sdk/central/client.rb', line 25

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

#teacher_enrollments(external_course_id = nil) ⇒ Object



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

def teacher_enrollments(external_course_id = nil)
  resource_path = '/api/teacher_enrollments'
  resource_path += "?external_course_id=#{external_course_id}" if external_course_id
  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