Class: SimplyReddit::Client
Constant Summary
collapse
- BASE_URL =
"https://oauth.reddit.com"
- DEFAULT_GRANT_TYPE =
"client_credentials"
- USER_AGENT =
"Ruby:SimplyReddit:v#{SimplyReddit::VERSION} (by unknown)"
Instance Method Summary
collapse
Methods inherited from BaseClient
#delete, #get, #post, #put
Constructor Details
#initialize(client_id:, secret:, username:, password:, adapter: Faraday.default_adapter) ⇒ Client
Returns a new instance of Client.
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/simply_reddit/client.rb', line 11
def initialize(client_id:, secret:, username:, password:, adapter: Faraday.default_adapter)
@user_agent = USER_AGENT
@client_id = client_id
@secret = secret
@username = username
@password = password
@access_token = request_access_token
super(
base_url: BASE_URL,
adapter: adapter,
headers: {
"User-Agent" => @user_agent,
"Authorization" => "Bearer #{@access_token}"
}
)
end
|
Instance Method Details
#me ⇒ Object
37
38
39
|
# File 'lib/simply_reddit/client.rb', line 37
def me
get("/api/v1/me")
end
|
#subreddit(name) ⇒ Object
29
30
31
|
# File 'lib/simply_reddit/client.rb', line 29
def subreddit(name)
SimplyReddit::Subreddit.new(client: self, name: name)
end
|
#user(username) ⇒ Object
33
34
35
|
# File 'lib/simply_reddit/client.rb', line 33
def user(username)
SimplyReddit::User.new(client: self, username: username)
end
|