Module: MangoApi::Users

Extended by:
UriProvider
Defined in:
lib/mangopay/api/service/users.rb

Overview

Provides API method delegates concerning the User entity.

Class Method Summary collapse

Methods included from UriProvider

provide_uri

Class Method Details

.all {|filter_request = FilterRequest.new| ... } ⇒ Array

Retrieves user entity pages. Allows configuration of paging and sorting parameters by yielding a filtering object to a provided block. When no filters are specified, will retrieve the first page of 10 newest results.

Allowed FilterRequest params:

  • page

  • per_page

  • sort_field and sort_direction

  • before_date

  • after_date

Yields:

Returns:

  • (Array)

    corresponding User entity objects



118
119
120
121
122
123
124
# File 'lib/mangopay/api/service/users.rb', line 118

def all
  uri = provide_uri(:get_users)
  filter_request = nil
  yield filter_request = FilterRequest.new if block_given?
  results = HttpClient.get(uri, filter_request)
  parse_results results
end

.create(user, id_key = nil) ⇒ User

Creates a new user entity.

User properties:

  • NaturalUser

    • first_name - required

    • last_name - required

    • birthday - required

    • nationality - required

    • country_of_residence - required

    • email - required

    • tag - optional

    • address - optional

    • occupation - optional

    • income_range - optional

    • capacity - optional

  • LegalUser

    • legal_person_type - required

    • name - required

    • legal_representative_birthday - required

    • legal_representative_country_of_residence - required

    • legal_representative_nationality - required

    • legal_representative_first_name - required

    • legal_representative_last_name - required

    • email - required

    • tag - optional

    • headquarters_address - optional

    • legal_representative_address - optional

    • legal_representative_email - optional

    • company_number - optional

User properties:

  • Optional

    • tag

    • declared_ubos

Parameters:

  • +user+ (User)

    model object of user to be created

  • +id_key+ (String)

    idempotency key for future response replication

Returns:

  • (User)

    the newly-created User entity object



49
50
51
52
53
# File 'lib/mangopay/api/service/users.rb', line 49

def create(user, id_key = nil)
  uri = provide_uri(:create_user, user)
  response = HttpClient.post(uri, user, id_key)
  parse response
end

.get(id) ⇒ User

Retrieves a user entity.

Parameters:

  • +id+ (String)

    ID of the user to be retrieved

Returns:

  • (User)

    the requested entity object



99
100
101
102
103
# File 'lib/mangopay/api/service/users.rb', line 99

def get(id)
  uri = provide_uri(:get_user, id)
  response = HttpClient.get(uri)
  parse response
end

.get_block_status(id) ⇒ Object



126
127
128
129
130
# File 'lib/mangopay/api/service/users.rb', line 126

def get_block_status(id)
  uri = provide_uri(:get_user_block_status, id)
  response = HttpClient.get(uri)
  parse response
end

.get_regulatory(id) ⇒ Object



132
133
134
135
136
# File 'lib/mangopay/api/service/users.rb', line 132

def get_regulatory(id)
  uri = provide_uri(:get_regulatory, id)
  response = HttpClient.get(uri)
  parse response
end

.update(user) ⇒ User

Updates the user entity identifiable by the provided user object’s ID.

User optional properties:

  • NaturalUser

    • tag

    • first_name

    • last_name

    • address

    • birthday

    • nationality

    • country_of_residence

    • occupation

    • income_range

    • email

  • Legal_user

    • tag

    • headquarters_address

    • name

    • legal_representative_address

    • legal_representative_birthday

    • legal_representative_country_of_residence

    • legal_representative_nationality

    • legal_representative_email

    • legal_representative_first_name

    • legal_representative_last_name

    • legal_person_type

    • company_number

and updated data

Parameters:

  • +user+ (User)

    user object with corresponding ID

Returns:

  • (User)

    the updated User entity object



87
88
89
90
91
92
93
# File 'lib/mangopay/api/service/users.rb', line 87

def update(user)
  uri = provide_uri :update_user,
                    user.person_type.to_s.downcase,
                    user.id
  response = HttpClient.put(uri, user)
  parse response
end