Class: NewDemoApiClient::AsyncGroupClient

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::AsyncGroupClient

Parameters:



372
373
374
# File 'lib/test_sdk/group/client.rb', line 372

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientNewDemoApiClient::AsyncRequestClient (readonly)



368
369
370
# File 'lib/test_sdk/group/client.rb', line 368

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:



640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
# File 'lib/test_sdk/group/client.rb', line 640

def create_user_role(user_id:, group_id:, role_id: nil, role_name: nil, request_options: nil)
  Async do
    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
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:



431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
# File 'lib/test_sdk/group/client.rb', line 431

def get(group_id:, request_options: nil)
  Async do
    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
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:



392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
# File 'lib/test_sdk/group/client.rb', line 392

def get_by_domain(domain:, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil)
  Async do
    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
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:



516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
# File 'lib/test_sdk/group/client.rb', line 516

def list_users(group_id:, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil)
  Async do
    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
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:



715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
# File 'lib/test_sdk/group/client.rb', line 715

def remove_user(user_id:, group_id:, request_options: nil)
  Async do
    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
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:



560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
# File 'lib/test_sdk/group/client.rb', line 560

def search_users(group_id:, name: nil, email: nil, sort_by: nil, sort_order: nil, page: nil, page_size: nil,
                 request_options: nil)
  Async do
    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
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:



471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
# File 'lib/test_sdk/group/client.rb', line 471

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)
  Async do
    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
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:



682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
# File 'lib/test_sdk/group/client.rb', line 682

def update_user_roles(user_id:, group_id:, role_ids:, request_options: nil)
  Async do
    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
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:



602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
# File 'lib/test_sdk/group/client.rb', line 602

def upload_group_avatar(group_id:, image:, request_options: nil)
  Async do
    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
end