Class: CloudApp::Account

Inherits:
Base
  • Object
show all
Defined in:
lib/cloudapp/account.rb

Overview

An ActiveResource-like interface through which to interract with the CloudApp API.

Examples:

Create a CloudApp account

CloudApp::Account.create :email => "[email protected]", :password => "towel"

Most other account actions require authentication first

CloudApp.authenticate "username", "password"

Usage via the Account class

# View account details
@account = CloudApp::Account.find

# Change default security
CloudApp::Account.update :private_items => false

# Change email
CloudApp::Account.update :email => "[email protected]", :current_password => "towel"

# Change password
CloudApp::Account.update :password => "happy frood", :current_password => "towel"

# Set custom domain
CloudApp::Account.update :domain => "dent.com", :domain_home_page => "http://hhgproject.org"

# Forgot password
CloudApp::Account.reset :email => "[email protected]"

Usage via the class instance

# Change default security
@account.update :private_items => false

# Change email
@account.update :email => "[email protected]", :current_password => "towel"

# Change password
@account.update :password => "happy frood", :current_password => "towel"

# Set custom domain
@account.update :domain => "dent.com", :domain_home_page => "http://hhgproject.org"

# Forgot password
@account.reset

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

authenticate

Constructor Details

#initialize(attributes = {}) ⇒ Account

Create a new CloudApp::Account object. Only used internally

Parameters:



102
103
104
# File 'lib/cloudapp/account.rb', line 102

def initialize(attributes = {})
  load(attributes)
end

Instance Attribute Details

#activated_atObject (readonly)

Returns the value of attribute activated_at.



95
96
97
# File 'lib/cloudapp/account.rb', line 95

def activated_at
  @activated_at
end

#alphaObject (readonly)

Returns the value of attribute alpha.



95
96
97
# File 'lib/cloudapp/account.rb', line 95

def alpha
  @alpha
end

#created_atObject (readonly)

Returns the value of attribute created_at.



95
96
97
# File 'lib/cloudapp/account.rb', line 95

def created_at
  @created_at
end

#domainObject (readonly)

Returns the value of attribute domain.



95
96
97
# File 'lib/cloudapp/account.rb', line 95

def domain
  @domain
end

#domain_home_pageObject (readonly)

Returns the value of attribute domain_home_page.



95
96
97
# File 'lib/cloudapp/account.rb', line 95

def domain_home_page
  @domain_home_page
end

#emailObject (readonly)

Returns the value of attribute email.



95
96
97
# File 'lib/cloudapp/account.rb', line 95

def email
  @email
end

#idObject (readonly)

Returns the value of attribute id.



95
96
97
# File 'lib/cloudapp/account.rb', line 95

def id
  @id
end

#private_itemsObject (readonly)

Returns the value of attribute private_items.



95
96
97
# File 'lib/cloudapp/account.rb', line 95

def private_items
  @private_items
end

#subscribedObject (readonly)

Returns the value of attribute subscribed.



95
96
97
# File 'lib/cloudapp/account.rb', line 95

def subscribed
  @subscribed
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



95
96
97
# File 'lib/cloudapp/account.rb', line 95

def updated_at
  @updated_at
end

Class Method Details

.create(opts = {}) ⇒ CloudApp::Account

Create a CloudApp account.

Examples:

Provide a user details param

{ :email => "[email protected]", :password => "towel" }

Parameters:

  • of (Hash)

    user credentials

Returns:



61
62
63
64
# File 'lib/cloudapp/account.rb', line 61

def self.create(opts = {})
  res = post "/register", :body => {:user => opts}
  res.ok? ? Account.new(res) : res
end

.findCloudApp::Account

Get the basic details of the authenticated account. Requires authentication.

Returns:



51
52
53
54
# File 'lib/cloudapp/account.rb', line 51

def self.find
  res = get "/account", :digest_auth => @@auth
  res.ok? ? Account.new(res) : res
end

.reset(opts = {}) ⇒ Boolean

Dispatch an email containing a link to reset the account’s password.

Examples:

Requires the account email address in a hash

{ :email => "[email protected]" }

Parameters:

  • account (Hash)

    credentials

Returns:

  • (Boolean)


90
91
92
93
# File 'lib/cloudapp/account.rb', line 90

def self.reset(opts = {})
  res = post "/reset", :body => {:user => opts}
  res.ok? ? true : res
end

.update(opts = {}) ⇒ CloudApp::Account

Modify the authenticated accounts details. Can change the default security of newly created items, the accounts email address, password, and custom domain details. Note that to custom domains requires and account with a Pro subscription. Requires authentication.

Examples:

Options for changing default security of new items

{ :private_items => false }

Options for changing email address

{ :email => "[email protected]", :current_password => "towel" }

Options for modifying password

{ :password => "happy frood", :current_password => "towel" }

Options for changing custom domain

{ :domain => "dent.com", :domain_home_page => "http://hhgproject.org" }

Parameters:

  • account (Hash)

    parameters

Returns:



80
81
82
83
# File 'lib/cloudapp/account.rb', line 80

def self.update(opts = {})
  res = put "/account", {:body => {:user => opts}, :digest_auth => @@auth}
  res.ok? ? Account.new(res) : res
end

Instance Method Details

#resetBoolean

Dispatch an email containing a link to reset the account’s password.

Returns:

  • (Boolean)


126
127
128
# File 'lib/cloudapp/account.rb', line 126

def reset
  self.class.reset :email => self.email
end

#update(opts = {}) ⇒ CloudApp::Account

Modify the authenticated accounts details. Can change the default security of newly created items, the accounts email address, password, and custom domain details. Note that to custom domains requires and account with a Pro subscription. Requires authentication.

Examples:

Options for changing default security of new items

{ :private_items => false }

Options for changing email address

{ :email => "[email protected]", :current_password => "towel" }

Options for modifying password

{ :password => "happy frood", :current_password => "towel" }

Options for changing custom domain

{ :domain => "dent.com", :domain_home_page => "http://hhgproject.org" }

Parameters:

  • account (Hash)

    parameters

Returns:



120
121
122
# File 'lib/cloudapp/account.rb', line 120

def update(opts = {})
  self.class.update opts
end