Class: WorkOS::Pipes

Inherits:
Object
  • Object
show all
Defined in:
lib/workos/pipes.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Pipes

Returns a new instance of Pipes.



9
10
11
# File 'lib/workos/pipes.rb', line 9

def initialize(client)
  @client = client
end

Instance Method Details

#authorize_data_integration(slug:, user_id:, organization_id: nil, return_to: nil, request_options: {}) ⇒ WorkOS::DataIntegrationAuthorizeUrlResponse

Get authorization URL

Parameters:

  • slug (String)

    The slug identifier of the provider (e.g., ‘github`, `slack`, `notion`).

  • user_id (String)

    The ID of the user to authorize.

  • organization_id (String, nil) (defaults to: nil)

    An organization ID to scope the authorization to a specific organization.

  • return_to (String, nil) (defaults to: nil)

    The URL to redirect the user to after authorization.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/workos/pipes.rb', line 20

def authorize_data_integration(
  slug:,
  user_id:,
  organization_id: nil,
  return_to: nil,
  request_options: {}
)
  body = {
    "user_id" => user_id,
    "organization_id" => organization_id,
    "return_to" => return_to
  }.compact
  response = @client.request(
    method: :post,
    path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}/authorize",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = WorkOS::DataIntegrationAuthorizeUrlResponse.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#create_data_integration_token(slug:, user_id:, organization_id: nil, request_options: {}) ⇒ WorkOS::DataIntegrationAccessTokenResponse

Get an access token for a connected account

Parameters:

  • slug (String)

    The identifier of the integration.

  • user_id (String)
  • organization_id (String, nil) (defaults to: nil)

    An [Organization](workos.com/docs/reference/organization) identifier. Optional parameter to scope the connection to a specific organization.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)

Returns:



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/workos/pipes.rb', line 50

def create_data_integration_token(
  slug:,
  user_id:,
  organization_id: nil,
  request_options: {}
)
  body = {
    "user_id" => user_id,
    "organization_id" => organization_id
  }.compact
  response = @client.request(
    method: :post,
    path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}/token",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = WorkOS::DataIntegrationAccessTokenResponse.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#delete_user_connected_account(user_id:, slug:, organization_id: nil, request_options: {}) ⇒ void

This method returns an undefined value.

Delete a connected account

Parameters:

  • user_id (String)
  • slug (String)

    The slug identifier of the provider (e.g., ‘github`, `slack`, `notion`).

  • organization_id (String, nil) (defaults to: nil)

    An [Organization](workos.com/docs/reference/organization) identifier. Optional parameter if the connection is scoped to an organization.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/workos/pipes.rb', line 105

def (
  user_id:,
  slug:,
  organization_id: nil,
  request_options: {}
)
  params = {
    "organization_id" => organization_id
  }.compact
  @client.request(
    method: :delete,
    path: "/user_management/users/#{WorkOS::Util.encode_path(user_id)}/connected_accounts/#{WorkOS::Util.encode_path(slug)}",
    auth: true,
    params: params,
    request_options: request_options
  )
  nil
end

#get_user_connected_account(user_id:, slug:, organization_id: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount

Get a connected account

Parameters:

  • user_id (String)
  • slug (String)

    The slug identifier of the provider (e.g., ‘github`, `slack`, `notion`).

  • organization_id (String, nil) (defaults to: nil)

    An [Organization](workos.com/docs/reference/organization) identifier. Optional parameter if the connection is scoped to an organization.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)

Returns:



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/workos/pipes.rb', line 78

def (
  user_id:,
  slug:,
  organization_id: nil,
  request_options: {}
)
  params = {
    "organization_id" => organization_id
  }.compact
  response = @client.request(
    method: :get,
    path: "/user_management/users/#{WorkOS::Util.encode_path(user_id)}/connected_accounts/#{WorkOS::Util.encode_path(slug)}",
    auth: true,
    params: params,
    request_options: request_options
  )
  result = WorkOS::ConnectedAccount.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#list_user_data_providers(user_id:, organization_id: nil, request_options: {}) ⇒ WorkOS::DataIntegrationsListResponse

List providers

Parameters:

  • user_id (String)

    A [User](workos.com/docs/reference/authkit/user) identifier to list providers and connected accounts for.

  • organization_id (String, nil) (defaults to: nil)

    An [Organization](workos.com/docs/reference/organization) identifier. Optional parameter to filter connections for a specific organization.

  • request_options (Hash) (defaults to: {})

    (see WorkOS::Types::RequestOptions)

Returns:



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/workos/pipes.rb', line 129

def list_user_data_providers(
  user_id:,
  organization_id: nil,
  request_options: {}
)
  params = {
    "organization_id" => organization_id
  }.compact
  response = @client.request(
    method: :get,
    path: "/user_management/users/#{WorkOS::Util.encode_path(user_id)}/data_providers",
    auth: true,
    params: params,
    request_options: request_options
  )
  result = WorkOS::DataIntegrationsListResponse.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end