Class: Tipjoy::Account
- Inherits:
-
Object
- Object
- Tipjoy::Account
- Includes:
- BulkInitializer, Requestor
- Defined in:
- lib/tipjoy/account.rb
Constant Summary collapse
- EXISTS_PATH =
"/user/exists/"- CREATE_PATH =
"/createTwitterAccount/"
Instance Attribute Summary collapse
-
#date_joined ⇒ Object
Returns the value of attribute date_joined.
-
#is_private ⇒ Object
Returns the value of attribute is_private.
-
#profile_image_url ⇒ Object
Returns the value of attribute profile_image_url.
-
#twitter_user_id ⇒ Object
Returns the value of attribute twitter_user_id.
-
#twitter_username ⇒ Object
Returns the value of attribute twitter_username.
-
#user_id ⇒ Object
Returns the value of attribute user_id.
-
#username ⇒ Object
Returns the value of attribute username.
-
#verified ⇒ Object
Returns the value of attribute verified.
Class Method Summary collapse
- .create_account(client, twitter_username) ⇒ Object
- .fetch_account_by_twitter_username(twitter_username) ⇒ Object
- .fetch_or_create_account_by_twitter_username(client, username) ⇒ Object
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Account
constructor
A new instance of Account.
Methods included from Requestor
Constructor Details
#initialize(options = {}) ⇒ Account
18 19 20 |
# File 'lib/tipjoy/account.rb', line 18 def initialize(={}) assign_attributes() end |
Instance Attribute Details
#date_joined ⇒ Object
Returns the value of attribute date_joined.
11 12 13 |
# File 'lib/tipjoy/account.rb', line 11 def date_joined @date_joined end |
#is_private ⇒ Object
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_url ⇒ Object
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_id ⇒ Object
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_username ⇒ Object
Returns the value of attribute twitter_username.
14 15 16 |
# File 'lib/tipjoy/account.rb', line 14 def twitter_username @twitter_username end |
#user_id ⇒ Object
Returns the value of attribute user_id.
10 11 12 |
# File 'lib/tipjoy/account.rb', line 10 def user_id @user_id end |
#username ⇒ Object
Returns the value of attribute username.
9 10 11 |
# File 'lib/tipjoy/account.rb', line 9 def username @username end |
#verified ⇒ Object
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.create_account(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" Account.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.fetch_account_by_twitter_username(twitter_username) json = tipjoy_request(:get, TIPJOY_BASE_URL + EXISTS_PATH + "?twitter_username=" + twitter_username) if json['exists'] Account.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.fetch_or_create_account_by_twitter_username(client, username) existing = fetch_account_by_twitter_username(username) return existing unless existing.nil? return create_account(client, username) end |