Class: SchoologyClient::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conn = nil) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/schoology_client/client.rb', line 9

def initialize(conn = nil)
  if conn.nil?
    # setup faraday connection using 2-legged oauth 1.0
    @connection = Faraday.new(url: SchoologyClient.configuration.url) do |faraday|
      faraday.request :json
      faraday.request :oauth, {
        consumer_key: SchoologyClient.configuration.oauth_consumer_key,
        consumer_secret: SchoologyClient.configuration.oauth_consumer_secret
      }

      faraday.response :json
    end
  else
    @connection = conn
  end
end

Instance Attribute Details

#oauth_consumer_keyObject (readonly)

Returns the value of attribute oauth_consumer_key.



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

def oauth_consumer_key
  @oauth_consumer_key
end

#oauth_consumer_secretObject (readonly)

Returns the value of attribute oauth_consumer_secret.



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

def oauth_consumer_secret
  @oauth_consumer_secret
end

#urlObject (readonly)

Returns the value of attribute url.



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

def url
  @url
end

Instance Method Details

#connectionObject



30
31
32
# File 'lib/schoology_client/client.rb', line 30

def connection
  @connection
end

#groupObject



26
27
28
# File 'lib/schoology_client/client.rb', line 26

def group
  GroupResource.new(self)
end