Class: NewDemoApiClient::GroupClient

Inherits:
Object
  • Object
show all
Defined in:
lib/test_sdk/group/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ NewDemoApiClient::GroupClient

Parameters:



18
19
20
# File 'lib/test_sdk/group/client.rb', line 18

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientNewDemoApiClient::RequestClient (readonly)



14
15
16
# File 'lib/test_sdk/group/client.rb', line 14

def request_client
  @request_client
end

Instance Method Details

#create_user_role(user_id:, group_id:, role_id: nil, role_name: nil, request_options: nil) ⇒ NewDemoApiClient::UserRoleResponse

Add a user role to a group.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.group.create_user_role(user_id: 1, group_id: 1)

Parameters:

  • user_id (Integer)
  • group_id (Integer)
  • role_id (Integer) (defaults to: nil)
  • role_name (String) (defaults to: nil)
  • request_options (NewDemoApiClient::RequestOptions) (defaults to: nil)

Returns:



274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/test_sdk/group/client.rb', line 274

def create_user_role(user_id:, group_id:, role_id: nil, role_name: nil, request_options: nil)
  response = @request_client.conn.post do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    unless request_options.nil? || request_options&.additional_query_parameters.nil?
      req.params = { **(request_options&.additional_query_parameters || {}) }.compact
    end
    req.body = {
      **(request_options&.additional_body_parameters || {}),
      role_id: role_id,
      role_name: role_name
    }.compact
    req.url "#{@request_client.get_url(request_options: request_options)}/api/v1/group/#{user_id}/user/#{group_id}"
  end
  NewDemoApiClient::UserRoleResponse.from_json(json_object: response.body)
end

#get(group_id:, request_options: nil) ⇒ NewDemoApiClient::GroupWithUsersResponse

Get a group by its ID.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.group.get(group_id: 1)

Parameters:

Returns:



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/test_sdk/group/client.rb', line 75

def get(group_id:, request_options: nil)
  response = @request_client.conn.get do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    unless request_options.nil? || request_options&.additional_query_parameters.nil?
      req.params = { **(request_options&.additional_query_parameters || {}) }.compact
    end
    unless request_options.nil? || request_options&.additional_body_parameters.nil?
      req.body = { **(request_options&.additional_body_parameters || {}) }.compact
    end
    req.url "#{@request_client.get_url(request_options: request_options)}/api/v1/group/#{group_id}"
  end
  NewDemoApiClient::GroupWithUsersResponse.from_json(json_object: response.body)
end

#get_by_domain(domain:, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil) ⇒ NewDemoApiClient::GroupWithUsersResponse

Lookup a group by its domain.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.group.get_by_domain(domain: "domain")

Parameters:

  • domain (String)
  • sort_by (String) (defaults to: nil)
  • sort_order (String) (defaults to: nil)
  • page (Integer) (defaults to: nil)
  • page_size (Integer) (defaults to: nil)
  • request_options (NewDemoApiClient::RequestOptions) (defaults to: nil)

Returns:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/test_sdk/group/client.rb', line 38

def get_by_domain(domain:, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil)
  response = @request_client.conn.get do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    req.params = {
      **(request_options&.additional_query_parameters || {}),
      "domain": domain,
      "sort_by": sort_by,
      "sort_order": sort_order,
      "page": page,
      "page_size": page_size
    }.compact
    unless request_options.nil? || request_options&.additional_body_parameters.nil?
      req.body = { **(request_options&.additional_body_parameters || {}) }.compact
    end
    req.url "#{@request_client.get_url(request_options: request_options)}/api/v1/group"
  end
  NewDemoApiClient::GroupWithUsersResponse.from_json(json_object: response.body)
end

#list_users(group_id:, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil) ⇒ NewDemoApiClient::PaginatedResponseGroupUser

Get all users in a group.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.group.list_users(group_id: 1)

Parameters:

  • group_id (Integer)
  • sort_by (String) (defaults to: nil)
  • sort_order (String) (defaults to: nil)
  • page (Integer) (defaults to: nil)
  • page_size (Integer) (defaults to: nil)
  • request_options (NewDemoApiClient::RequestOptions) (defaults to: nil)

Returns:



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/test_sdk/group/client.rb', line 156

def list_users(group_id:, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil)
  response = @request_client.conn.get do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    req.params = {
      **(request_options&.additional_query_parameters || {}),
      "sort_by": sort_by,
      "sort_order": sort_order,
      "page": page,
      "page_size": page_size
    }.compact
    unless request_options.nil? || request_options&.additional_body_parameters.nil?
      req.body = { **(request_options&.additional_body_parameters || {}) }.compact
    end
    req.url "#{@request_client.get_url(request_options: request_options)}/api/v1/group/#{group_id}/user/all"
  end
  NewDemoApiClient::PaginatedResponseGroupUser.from_json(json_object: response.body)
end

#remove_user(user_id:, group_id:, request_options: nil) ⇒ NewDemoApiClient::UserRoleResponse

Remove a user from a group.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.group.remove_user(user_id: 1, group_id: 1)

Parameters:

Returns:



345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# File 'lib/test_sdk/group/client.rb', line 345

def remove_user(user_id:, group_id:, request_options: nil)
  response = @request_client.conn.delete do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    unless request_options.nil? || request_options&.additional_query_parameters.nil?
      req.params = { **(request_options&.additional_query_parameters || {}) }.compact
    end
    unless request_options.nil? || request_options&.additional_body_parameters.nil?
      req.body = { **(request_options&.additional_body_parameters || {}) }.compact
    end
    req.url "#{@request_client.get_url(request_options: request_options)}/api/v1/group/#{user_id}/user/#{group_id}"
  end
  NewDemoApiClient::UserRoleResponse.from_json(json_object: response.body)
end

#search_users(group_id:, name: nil, email: nil, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil) ⇒ NewDemoApiClient::PaginatedResponseGroupUser

Get all users in a group.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.group.search_users(group_id: 1)

Parameters:

  • group_id (Integer)
  • name (String) (defaults to: nil)
  • email (String) (defaults to: nil)
  • sort_by (String) (defaults to: nil)
  • sort_order (String) (defaults to: nil)
  • page (Integer) (defaults to: nil)
  • page_size (Integer) (defaults to: nil)
  • request_options (NewDemoApiClient::RequestOptions) (defaults to: nil)

Returns:



198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/test_sdk/group/client.rb', line 198

def search_users(group_id:, name: nil, email: nil, sort_by: nil, sort_order: nil, page: nil, page_size: nil,
                 request_options: nil)
  response = @request_client.conn.get do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    req.params = {
      **(request_options&.additional_query_parameters || {}),
      "name": name,
      "email": email,
      "sort_by": sort_by,
      "sort_order": sort_order,
      "page": page,
      "page_size": page_size
    }.compact
    unless request_options.nil? || request_options&.additional_body_parameters.nil?
      req.body = { **(request_options&.additional_body_parameters || {}) }.compact
    end
    req.url "#{@request_client.get_url(request_options: request_options)}/api/v1/group/#{group_id}/user/search"
  end
  NewDemoApiClient::PaginatedResponseGroupUser.from_json(json_object: response.body)
end

#update(group_id:, name: nil, domain: nil, thumbnail_url: nil, analysis_email: nil, data_api_access: nil, account_manager_id: nil, request_options: nil) ⇒ NewDemoApiClient::GroupWithUsersResponse

Update a group.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.group.update(group_id: 1)

Parameters:

  • group_id (Integer)
  • name (String) (defaults to: nil)
  • domain (String) (defaults to: nil)
  • thumbnail_url (String) (defaults to: nil)

    The thumbnail URL of the group

  • analysis_email (String) (defaults to: nil)

    The email address for analysis to be sent to

  • data_api_access (Boolean) (defaults to: nil)

    Whether the group has access to the data API

  • account_manager_id (Integer) (defaults to: nil)
  • request_options (NewDemoApiClient::RequestOptions) (defaults to: nil)

Returns:



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/test_sdk/group/client.rb', line 113

def update(group_id:, name: nil, domain: nil, thumbnail_url: nil, analysis_email: nil, data_api_access: nil,
           account_manager_id: nil, request_options: nil)
  response = @request_client.conn.put do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    unless request_options.nil? || request_options&.additional_query_parameters.nil?
      req.params = { **(request_options&.additional_query_parameters || {}) }.compact
    end
    req.body = {
      **(request_options&.additional_body_parameters || {}),
      name: name,
      domain: domain,
      thumbnail_url: thumbnail_url,
      analysis_email: analysis_email,
      data_api_access: data_api_access,
      account_manager_id: 
    }.compact
    req.url "#{@request_client.get_url(request_options: request_options)}/api/v1/group/#{group_id}"
  end
  NewDemoApiClient::GroupWithUsersResponse.from_json(json_object: response.body)
end

#update_user_roles(user_id:, group_id:, role_ids:, request_options: nil) ⇒ NewDemoApiClient::UserRoleResponse

Update the roles of a user in a group.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.group.update_user_roles(
  user_id: 1,
  group_id: 1,
  role_ids: [1]
)

Parameters:

Returns:



314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
# File 'lib/test_sdk/group/client.rb', line 314

def update_user_roles(user_id:, group_id:, role_ids:, request_options: nil)
  response = @request_client.conn.put do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    unless request_options.nil? || request_options&.additional_query_parameters.nil?
      req.params = { **(request_options&.additional_query_parameters || {}) }.compact
    end
    req.body = { **(request_options&.additional_body_parameters || {}), role_ids: role_ids }.compact
    req.url "#{@request_client.get_url(request_options: request_options)}/api/v1/group/#{user_id}/user/#{group_id}"
  end
  NewDemoApiClient::UserRoleResponse.from_json(json_object: response.body)
end

#upload_group_avatar(group_id:, image:, request_options: nil) ⇒ NewDemoApiClient::GroupResponse

Upload an avatar for a group.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.group.upload_group_avatar(group_id: 1, image: my_file.txt)

Parameters:

Returns:



238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/test_sdk/group/client.rb', line 238

def upload_group_avatar(group_id:, image:, request_options: nil)
  response = @request_client.conn.post do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    unless request_options.nil? || request_options&.additional_query_parameters.nil?
      req.params = { **(request_options&.additional_query_parameters || {}) }.compact
    end
    req.body = {
      **(request_options&.additional_body_parameters || {}),
      image: NewDemoApiClient::FileUtilities.as_faraday_multipart(file_like: image)
    }.compact
    req.url "#{@request_client.get_url(request_options: request_options)}/api/v1/group/#{group_id}/avatar"
  end
  NewDemoApiClient::GroupResponse.from_json(json_object: response.body)
end