Module: UserManagementApi::ClientMethods::Registrations

Included in:
UserManagementApi::Client
Defined in:
lib/user_management_api/client_methods/registrations.rb

Instance Method Summary collapse

Instance Method Details

#search_registrations(project, criteria = {}) ⇒ Object

returns a list of registrations for the given project registrations may be filtered by setting criteria keys as follows: any of the following keys will filter data: valid first_name last_name unique_id email

The following keys will reflect the order and paging of the returned data: sort_column: name of the column to sort by. May be one of last_name, first_name, or email sort_direction: asc or desc page: page number to return per: number of users per page (defaults to 25)

The returned object will be a PagedCollection instance



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/user_management_api/client_methods/registrations.rb', line 33

def search_registrations(project, criteria = {})
  query = {}
  criteria = criteria.stringify_keys

  %w(first_name last_name unique_id email sort_column sort_direction page per valid).each do |prop|
    query[prop] = criteria[prop] if criteria[prop]
  end

  res = conn.get("registrations/#{project}", query)

  build_paged_collection(Registration, 'registrations', res)
end

#set_registration_custom_attributes(project, unique_id, attributes) ⇒ Object

Sets the given attributes as custom attributes on the given registration. Performs a merge on any existing attributes. Any keys with nil or empty values will be deleted.



48
49
50
51
# File 'lib/user_management_api/client_methods/registrations.rb', line 48

def set_registration_custom_attributes(project, unique_id, attributes)
  res = conn.patch("registrations/#{project}/#{unique_id}/custom_attributes", MultiJson.dump(custom_attributes: attributes))
  build_entity(Registration, res)
end

#user_registration(project, unique_id) ⇒ Object

Returns the registration given by the user and project



12
13
14
15
# File 'lib/user_management_api/client_methods/registrations.rb', line 12

def user_registration(project, unique_id)
  res = conn.get("registrations/#{project}/#{unique_id}")
  build_entity(Registration, res)
end

#user_registrations(unique_id) ⇒ Object

Returns all registrations owned by the given user



6
7
8
9
# File 'lib/user_management_api/client_methods/registrations.rb', line 6

def user_registrations(unique_id)
  res = conn.get("registrations/#{unique_id}")
  build_collection(Registration, res)
end