Class: Fotolia::User
- Inherits:
-
Object
- Object
- Fotolia::User
- Defined in:
- lib/fotolia/user.rb
Overview
Represents a Fotolia user.
Won’t yield sensible results in Partner API as the user methods are not available there. Note that Reseller and Business API are limited to the user the API key belongs to.
Instance Attribute Summary collapse
-
#login ⇒ Object
readonly
Returns the value of attribute login.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
Instance Method Summary collapse
-
#absolute_ranking ⇒ Object
absolute ranking ( top sellers ever).
-
#count_media_accepted ⇒ Object
number of accepted media.
-
#count_media_purchased ⇒ Object
number of purchased media.
-
#count_media_sold ⇒ Object
number of sold media.
-
#count_media_uploaded ⇒ Object
number of uploaded media.
- #count_member_bought_photos(time_range = :day, date_period = nil) ⇒ Object
- #count_member_downloaded_photos(time_range = :day, date_period = nil) ⇒ Object
- #count_member_earned_credits(time_range = :day, date_period = nil) ⇒ Object
- #count_member_viewed_photos(time_range = :day, date_period = nil) ⇒ Object
-
#credit_value ⇒ Object
how much is one of the user’s credits worth?.
-
#credits ⇒ Object
the user’s credits.
-
#currency_name ⇒ Object
the name of the currency #credit_value is in.
-
#currency_symbol ⇒ Object
the symbol of the currency #credit_value is in.
-
#galleries ⇒ Object
Returns an array of galleries the user has created.
-
#id ⇒ Object
the user’s id.
-
#initialize(fotolia_client, login, password) ⇒ User
constructor
A new instance of User.
-
#language ⇒ Object
the user’s language.
-
#relative_ranking ⇒ Object
relative ranking ( top seller in 7 days).
-
#reload_data ⇒ Object
reloads the statistical data when requested next time.
Constructor Details
#initialize(fotolia_client, login, password) ⇒ User
Returns a new instance of User.
12 13 14 15 16 |
# File 'lib/fotolia/user.rb', line 12 def initialize(fotolia_client, login, password) @fotolia = fotolia_client @login = login @password = password end |
Instance Attribute Details
#login ⇒ Object (readonly)
Returns the value of attribute login.
10 11 12 |
# File 'lib/fotolia/user.rb', line 10 def login @login end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
10 11 12 |
# File 'lib/fotolia/user.rb', line 10 def password @password end |
Instance Method Details
#absolute_ranking ⇒ Object
absolute ranking ( top sellers ever)
101 102 103 |
# File 'lib/fotolia/user.rb', line 101 def absolute_ranking user_stats['ranking_absolute'] end |
#count_media_accepted ⇒ Object
number of accepted media
80 81 82 |
# File 'lib/fotolia/user.rb', line 80 def count_media_accepted user_stats['nb_media_accepted'] end |
#count_media_purchased ⇒ Object
number of purchased media
87 88 89 |
# File 'lib/fotolia/user.rb', line 87 def count_media_purchased user_stats['nb_media_purchased'] end |
#count_media_sold ⇒ Object
number of sold media
94 95 96 |
# File 'lib/fotolia/user.rb', line 94 def count_media_sold user_stats['nb_media_sold'] end |
#count_media_uploaded ⇒ Object
number of uploaded media
73 74 75 |
# File 'lib/fotolia/user.rb', line 73 def count_media_uploaded user_stats['nb_media_uploaded'] end |
#count_member_bought_photos(time_range = :day, date_period = nil) ⇒ Object
See services.fotolia.com/Services/API/Method/getUserAdvancedStats
Parameters
- time_range
-
Group results by :day, :week, :month, :quarter or :year
- date_period
-
The period for which the value shall be returned. Is optional. May be one of :all, :today, :yesterday, :one_day, :two_days, :three_days, :one_week, :one_month or an array of two Time objects: The first is taken as starting date, the latter as end.
141 142 143 |
# File 'lib/fotolia/user.rb', line 141 def count_member_bought_photos(time_range = :day, date_period = nil) advanced_user_stats('member_bought_photos', time_range, date_period) end |
#count_member_downloaded_photos(time_range = :day, date_period = nil) ⇒ Object
See services.fotolia.com/Services/API/Method/getUserAdvancedStats
Parameters
- time_range
-
Group results by :day, :week, :month, :quarter or :year
- date_period
-
The period for which the value shall be returned. Is optional. May be one of :all, :today, :yesterday, :one_day, :two_days, :three_days, :one_week, :one_month or an array of two Time objects: The first is taken as starting date, the latter as end.
130 131 132 |
# File 'lib/fotolia/user.rb', line 130 def count_member_downloaded_photos(time_range = :day, date_period = nil) advanced_user_stats('member_downloaded_photos', time_range, date_period) end |
#count_member_earned_credits(time_range = :day, date_period = nil) ⇒ Object
See services.fotolia.com/Services/API/Method/getUserAdvancedStats
Parameters
- time_range
-
Group results by :day, :week, :month, :quarter or :year
- date_period
-
The period for which the value shall be returned. Is optional. May be one of :all, :today, :yesterday, :one_day, :two_days, :three_days, :one_week, :one_month or an array of two Time objects: The first is taken as starting date, the latter as end.
152 153 154 |
# File 'lib/fotolia/user.rb', line 152 def count_member_earned_credits(time_range = :day, date_period = nil) advanced_user_stats('member_earned_credits', time_range, date_period) end |
#count_member_viewed_photos(time_range = :day, date_period = nil) ⇒ Object
See services.fotolia.com/Services/API/Method/getUserAdvancedStats
Parameters
- time_range
-
Group results by :day, :week, :month, :quarter or :year
- date_period
-
The period for which the value shall be returned. Is optional. May be one of :all, :today, :yesterday, :one_day, :two_days, :three_days, :one_week, :one_month or an array of two Time objects: The first is taken as starting date, the latter as end.
119 120 121 |
# File 'lib/fotolia/user.rb', line 119 def count_member_viewed_photos(time_range = :day, date_period = nil) advanced_user_stats('member_viewed_photos', time_range, date_period) end |
#credit_value ⇒ Object
how much is one of the user’s credits worth?
52 53 54 |
# File 'lib/fotolia/user.rb', line 52 def credit_value user_data['credit_value'] end |
#credits ⇒ Object
the user’s credits
45 46 47 |
# File 'lib/fotolia/user.rb', line 45 def credits user_data['nb_credits'] end |
#currency_name ⇒ Object
the name of the currency #credit_value is in
59 60 61 |
# File 'lib/fotolia/user.rb', line 59 def currency_name user_data['currency_name'] end |
#currency_symbol ⇒ Object
the symbol of the currency #credit_value is in
66 67 68 |
# File 'lib/fotolia/user.rb', line 66 def currency_symbol user_data['currency_symbol'] end |
#galleries ⇒ Object
Returns an array of galleries the user has created.
159 160 161 162 163 164 165 |
# File 'lib/fotolia/user.rb', line 159 def galleries raise Fotolia::LoginRequiredError unless @fotolia.logged_in? res = @fotolia.remote_call('getUserGalleries', @fotolia.session_id) res.collect{|g| Fotolia::Gallery.new(@fotolia, g)} end |
#id ⇒ Object
the user’s id
29 30 31 |
# File 'lib/fotolia/user.rb', line 29 def id self.user_data['id'] end |
#language ⇒ Object
the user’s language
returns a Fotolia::Language object
38 39 40 |
# File 'lib/fotolia/user.rb', line 38 def language Fotolia::Language.new(self.user_data['language_id']) end |
#relative_ranking ⇒ Object
relative ranking ( top seller in 7 days)
108 109 110 |
# File 'lib/fotolia/user.rb', line 108 def relative_ranking user_stats['ranking_relative'] end |
#reload_data ⇒ Object
reloads the statistical data when requested next time
21 22 23 24 |
# File 'lib/fotolia/user.rb', line 21 def reload_data @user_data = nil @user_stats = nil end |