Module: RedditKit::Client::Apps

Included in:
RedditKit::Client
Defined in:
lib/redditkit/client/apps.rb

Overview

Methods for operating on apps in the current user’s account.

Instance Method Summary collapse

Instance Method Details

#add_developer(user, app_identifier) ⇒ Object

Add a user as a developer of an app.

Parameters:

  • user (String, RedditKit::User)

    The username of the user to add, or a RedditKit::User.

  • app_identifier (String)

    The identifier of the app.



43
44
45
46
47
48
# File 'lib/redditkit/client/apps.rb', line 43

def add_developer(user, app_identifier)
  username = extract_string user, :username
  parameters = { :name => username, :client_id => app_identifier }

  post 'api/adddeveloper', parameters
end

#create_app(name, options = {}) ⇒ Object Also known as: update_app

Create or update an app.

Parameters:

  • name (String)

    The app’s name.

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • description (String)

    The app’s description.

  • about_url (String)

    The app’s URL.

  • redirect_url (String)

    The app’s redirect URL.

  • app_identifier (String)

    The identifier of the app, if you are updating an existing one.



14
15
16
17
18
19
20
21
22
# File 'lib/redditkit/client/apps.rb', line 14

def create_app(name, options = {})
  description = options[:description]
  about_url = options[:about_url]
  redirect_url = options[:redirect_url]
  app_identifier = options[:app_identifier]
  parameters = { :client_id => app_identifier, :name => name, :description => description, :about_url => about_url, :redirect_uri => redirect_url }

  post('api/updateapp', parameters)
end

#delete_app(app_identifier) ⇒ Object

Delete an app.

Parameters:

  • app_identifier (String)

    The identifier of the app.



28
29
30
# File 'lib/redditkit/client/apps.rb', line 28

def delete_app(app_identifier)
  post 'api/deleteapp', :client_id => app_identifier
end

#remove_developer(user, app_identifier) ⇒ Object

Remove an app’s developer.

Parameters:

  • user (String, RedditKit::User)

    The username of the user to add, or a RedditKit::User.

  • app_identifier (String)

    The identifier of the app.



54
55
56
57
58
59
# File 'lib/redditkit/client/apps.rb', line 54

def remove_developer(user, app_identifier)
  username = extract_string user, :username
  parameters = { :name => username, :client_id => app_identifier }

  post('api/removedeveloper', parameters)
end

#revoke_app(app_identifier) ⇒ Object

Revoke an app.

Parameters:

  • app_identifier (String)

    The identifier of the app.



35
36
37
# File 'lib/redditkit/client/apps.rb', line 35

def revoke_app(app_identifier)
  post 'api/revokeapp', :client_id => app_identifier
end