Class: SchoologyClient::Client
- Inherits:
-
Object
- Object
- SchoologyClient::Client
- Defined in:
- lib/schoology_client/client.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#oauth_consumer_key ⇒ Object
readonly
Returns the value of attribute oauth_consumer_key.
-
#oauth_consumer_secret ⇒ Object
readonly
Returns the value of attribute oauth_consumer_secret.
-
#stubs ⇒ Object
readonly
Returns the value of attribute stubs.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #connection ⇒ Object
- #group ⇒ Object
-
#initialize(adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 17 18 |
# File 'lib/schoology_client/client.rb', line 10 def initialize(adapter: Faraday.default_adapter, stubs: nil) @adapter = adapter @oauth_consumer_key = SchoologyClient.configuration.oauth_consumer_key @oauth_consumer_secret = SchoologyClient.configuration.oauth_consumer_secret @url = SchoologyClient.configuration.url #used for specs @stubs = stubs end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
8 9 10 |
# File 'lib/schoology_client/client.rb', line 8 def adapter @adapter end |
#oauth_consumer_key ⇒ Object (readonly)
Returns the value of attribute oauth_consumer_key.
8 9 10 |
# File 'lib/schoology_client/client.rb', line 8 def oauth_consumer_key @oauth_consumer_key end |
#oauth_consumer_secret ⇒ Object (readonly)
Returns the value of attribute oauth_consumer_secret.
8 9 10 |
# File 'lib/schoology_client/client.rb', line 8 def oauth_consumer_secret @oauth_consumer_secret end |
#stubs ⇒ Object (readonly)
Returns the value of attribute stubs.
8 9 10 |
# File 'lib/schoology_client/client.rb', line 8 def stubs @stubs end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
8 9 10 |
# File 'lib/schoology_client/client.rb', line 8 def url @url end |
Instance Method Details
#connection ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/schoology_client/client.rb', line 24 def connection # setup faraday connection using 2-legged oauth 1.0 connection = Faraday.new(url: @url) do |faraday| faraday.request :json faraday.request :oauth, { consumer_key: @oauth_consumer_key, consumer_secret: @oauth_consumer_secret } faraday.response :json faraday.adapter @adapter, @stubs end connection end |
#group ⇒ Object
20 21 22 |
# File 'lib/schoology_client/client.rb', line 20 def group GroupResource.new(self) end |