Class: Tipjoy::Account

Inherits:
Object
  • Object
show all
Includes:
BulkInitializer, Requestor
Defined in:
lib/tipjoy/account.rb

Constant Summary collapse

EXISTS_PATH =
"/user/exists/"
CREATE_PATH =
"/createTwitterAccount/"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Requestor

included

Constructor Details

#initialize(options = {}) ⇒ Account



18
19
20
# File 'lib/tipjoy/account.rb', line 18

def initialize(options={})
  assign_attributes(options)
end

Instance Attribute Details

#date_joinedObject

Returns the value of attribute date_joined.



11
12
13
# File 'lib/tipjoy/account.rb', line 11

def date_joined
  @date_joined
end

#is_privateObject

Returns the value of attribute is_private.



12
13
14
# File 'lib/tipjoy/account.rb', line 12

def is_private
  @is_private
end

#profile_image_urlObject

Returns the value of attribute profile_image_url.



16
17
18
# File 'lib/tipjoy/account.rb', line 16

def profile_image_url
  @profile_image_url
end

#twitter_user_idObject

Returns the value of attribute twitter_user_id.



15
16
17
# File 'lib/tipjoy/account.rb', line 15

def twitter_user_id
  @twitter_user_id
end

#twitter_usernameObject

Returns the value of attribute twitter_username.



14
15
16
# File 'lib/tipjoy/account.rb', line 14

def twitter_username
  @twitter_username
end

#user_idObject

Returns the value of attribute user_id.



10
11
12
# File 'lib/tipjoy/account.rb', line 10

def user_id
  @user_id
end

#usernameObject

Returns the value of attribute username.



9
10
11
# File 'lib/tipjoy/account.rb', line 9

def username
  @username
end

#verifiedObject

Returns the value of attribute verified.



13
14
15
# File 'lib/tipjoy/account.rb', line 13

def verified
  @verified
end

Class Method Details

.create_account(client, twitter_username) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/tipjoy/account.rb', line 22

def self.(client, twitter_username)
  header  = client.oauth_signature_header("http://twitter.com/account/verify_credentials.json")
  json = tipjoy_request(:post, TIPJOY_BASE_URL + EXISTS_PATH, {:twitter_username=> twitter_username, :twitter_oauth_password => header})
  if json['result'] == "success"
    .new(json.merge(:twitter_username=> twitter_username))
  else
    nil
  end
end

.fetch_account_by_twitter_username(twitter_username) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/tipjoy/account.rb', line 32

def self.(twitter_username)
  json = tipjoy_request(:get, TIPJOY_BASE_URL + EXISTS_PATH + "?twitter_username=" + twitter_username)

  if json['exists']
    .new(json)
  else
    nil
  end
end

.fetch_or_create_account_by_twitter_username(client, username) ⇒ Object



42
43
44
45
46
# File 'lib/tipjoy/account.rb', line 42

def self.(client, username)
  existing = (username)
  return existing unless existing.nil?
  return (client, username)
end