Class: Fotolia::User

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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, , password)
  @fotolia = fotolia_client
  @login = 
  @password = password
end

Instance Attribute Details

#loginObject (readonly)

Returns the value of attribute login.



10
11
12
# File 'lib/fotolia/user.rb', line 10

def 
  @login
end

#passwordObject (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_rankingObject

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_acceptedObject

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_purchasedObject

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_soldObject

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_uploadedObject

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_valueObject

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

#creditsObject

the user’s credits



45
46
47
# File 'lib/fotolia/user.rb', line 45

def credits
  user_data['nb_credits']
end

#currency_nameObject

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_symbolObject

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

#galleriesObject

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

#idObject

the user’s id



29
30
31
# File 'lib/fotolia/user.rb', line 29

def id
  self.user_data['id']
end

#languageObject

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_rankingObject

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_dataObject

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