Class: FriendlyScore::API

Inherits:
Object
  • Object
show all
Defined in:
lib/friendly_score/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(application_id, application_secret) ⇒ API

A new instance of API.

Parameters:

  • application_id (Integer)

    application id

  • application_secret (String)

    application secret



9
10
11
12
# File 'lib/friendly_score/api.rb', line 9

def initialize application_id, application_secret
  @application_id = application_id
  @application_secret = application_secret
end

Instance Attribute Details

#application_idObject (readonly)

Returns the value of attribute application_id.



3
4
5
# File 'lib/friendly_score/api.rb', line 3

def application_id
  @application_id
end

#application_secretObject (readonly)

Returns the value of attribute application_secret.



3
4
5
# File 'lib/friendly_score/api.rb', line 3

def application_secret
  @application_secret
end

Instance Method Details

#show(id) ⇒ FriendlyScore::User

Returns user data (api: ‘api/show’)

Parameters:

  • id (Integer)

    identificator of user

Returns:



18
19
20
21
# File 'lib/friendly_score/api.rb', line 18

def show id
  endpoint = get_endpoint Endpoints::Show
  endpoint.perform id
end

#show_partner_user(partner_user_id) ⇒ FriendlyScore::User

Returns partner user

Parameters:

  • partner_user_id (String)

    identificaotr of partner user

Returns:



27
28
29
30
# File 'lib/friendly_score/api.rb', line 27

def show_partner_user partner_user_id
  endpoint = get_endpoint Endpoints::ShowPartnerUser
  endpoint.perform partner_user_id
end

#user_positive(id, positive) ⇒ Object

Sets is user positive or not

Parameters:

  • id (Integer)

    users identificator

  • positive (Integer)

    1 if user is positive, 0 if not



36
37
38
39
40
# File 'lib/friendly_score/api.rb', line 36

def user_positive id, positive
  endpoint = get_endpoint Endpoints::UserPositive
  endpoint.validate id, positive
  endpoint.perform id, positive
end

#user_status(id, status, status_description) ⇒ Object

Sets users status with description

Parameters:

  • id (Integer)

    users identificator

  • status (Integer)

    any integer number

  • status_description (String)

    status description



47
48
49
50
# File 'lib/friendly_score/api.rb', line 47

def user_status id, status, status_description
  endpoint = get_endpoint Endpoints::UserStatus
  endpoint.perform id, status, status_description
end

#usersList<FriendlyScore::User>

List of all application users

Returns:



55
56
57
58
# File 'lib/friendly_score/api.rb', line 55

def users
  endpoint = get_endpoint Endpoints::Users
  endpoint.perform
end