Class: WorkOS::Pipes
- Inherits:
-
Object
- Object
- WorkOS::Pipes
- Defined in:
- lib/workos/pipes.rb
Instance Method Summary collapse
-
#authorize_data_integration(slug:, user_id:, organization_id: nil, return_to: nil, request_options: {}) ⇒ WorkOS::DataIntegrationAuthorizeUrlResponse
Get authorization URL.
-
#create_data_integration(provider:, description: WorkOS::OMIT, enabled: nil, scopes: WorkOS::OMIT, auth_methods: nil, credentials: nil, api_key: nil, custom_provider: nil, request_options: {}) ⇒ WorkOS::DataIntegration
Create a data integration.
-
#create_data_integration_credential(slug:, user_id:, organization_id: nil, request_options: {}) ⇒ WorkOS::DataIntegrationCredentialsResponse
Vend credentials for a connected account.
-
#create_user_connected_account(user_id:, slug:, access_token: nil, refresh_token: nil, expires_at: nil, scopes: nil, state: nil, organization_id: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount
Import a connected account.
-
#delete_data_integration(slug:, request_options: {}) ⇒ void
Delete a data integration.
-
#delete_user_connected_account(user_id:, slug:, organization_id: nil, request_options: {}) ⇒ void
Delete a connected account.
-
#get_access_token(provider:, user_id:, organization_id: WorkOS::OMIT, request_options: {}) ⇒ WorkOS::DataIntegrationAccessTokenResponse
Get an access token for a connected account.
-
#get_data_integration(slug:, request_options: {}) ⇒ WorkOS::DataIntegration
Get a data integration.
-
#get_user_connected_account(user_id:, slug:, organization_id: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount
Get a connected account.
-
#initialize(client) ⇒ Pipes
constructor
A new instance of Pipes.
-
#list_data_integrations(before: nil, after: nil, limit: 10, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::DataIntegration>
List data integrations.
-
#list_user_data_providers(user_id:, organization_id: nil, request_options: {}) ⇒ WorkOS::DataIntegrationsListResponse
List providers for a user.
-
#update_data_integration(slug:, description: WorkOS::OMIT, enabled: nil, scopes: WorkOS::OMIT, credentials: nil, api_key: nil, custom_provider: nil, request_options: {}) ⇒ WorkOS::DataIntegration
Update a data integration.
-
#update_data_integration_api_key(slug:, user_id:, secret:, organization_id: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount
Upsert an API key for a connected account.
-
#update_user_connected_account(user_id:, slug:, access_token: nil, refresh_token: nil, expires_at: nil, scopes: nil, state: nil, organization_id: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount
Update a connected account.
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
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/workos/pipes.rb', line 215 def ( 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: ) 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(provider:, description: WorkOS::OMIT, enabled: nil, scopes: WorkOS::OMIT, auth_methods: nil, credentials: nil, api_key: nil, custom_provider: nil, request_options: {}) ⇒ WorkOS::DataIntegration
Create a data integration
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/workos/pipes.rb', line 68 def create_data_integration( provider:, description: WorkOS::OMIT, enabled: nil, scopes: WorkOS::OMIT, auth_methods: nil, credentials: nil, api_key: nil, custom_provider: nil, request_options: {} ) body = { "provider" => provider, "enabled" => enabled, "auth_methods" => auth_methods, "credentials" => credentials, "api_key" => api_key, "custom_provider" => custom_provider }.compact body["description"] = description unless description.equal?(WorkOS::OMIT) body["scopes"] = scopes unless scopes.equal?(WorkOS::OMIT) response = @client.request( method: :post, path: "/data-integrations", auth: true, body: body, request_options: ) result = WorkOS::DataIntegration.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_credential(slug:, user_id:, organization_id: nil, request_options: {}) ⇒ WorkOS::DataIntegrationCredentialsResponse
Vend credentials for a connected account
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/workos/pipes.rb', line 245 def create_data_integration_credential( 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)}/credentials", auth: true, body: body, request_options: ) result = WorkOS::DataIntegrationCredentialsResponse.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_user_connected_account(user_id:, slug:, access_token: nil, refresh_token: nil, expires_at: nil, scopes: nil, state: nil, organization_id: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount
Import a connected account
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
# File 'lib/workos/pipes.rb', line 333 def create_user_connected_account( user_id:, slug:, access_token: nil, refresh_token: nil, expires_at: nil, scopes: nil, state: nil, organization_id: nil, request_options: {} ) params = { "organization_id" => organization_id }.compact body = { "access_token" => access_token, "refresh_token" => refresh_token, "expires_at" => expires_at, "scopes" => scopes, "state" => state }.compact response = @client.request( method: :post, path: "/user_management/users/#{WorkOS::Util.encode_path(user_id)}/connected_accounts/#{WorkOS::Util.encode_path(slug)}", auth: true, params: params, body: body, 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 |
#delete_data_integration(slug:, request_options: {}) ⇒ void
This method returns an undefined value.
Delete a data integration
164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/workos/pipes.rb', line 164 def delete_data_integration( slug:, request_options: {} ) @client.request( method: :delete, path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}", auth: true, request_options: ) nil end |
#delete_user_connected_account(user_id:, slug:, organization_id: nil, request_options: {}) ⇒ void
This method returns an undefined value.
Delete a connected account
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 |
# File 'lib/workos/pipes.rb', line 418 def delete_user_connected_account( 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: ) nil end |
#get_access_token(provider:, user_id:, organization_id: WorkOS::OMIT, request_options: {}) ⇒ WorkOS::DataIntegrationAccessTokenResponse
Get an access token for a connected account
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/workos/pipes.rb', line 273 def get_access_token( provider:, user_id:, organization_id: WorkOS::OMIT, request_options: {} ) body = { "user_id" => user_id } body["organization_id"] = organization_id unless organization_id.equal?(WorkOS::OMIT) response = @client.request( method: :post, path: "/data-integrations/#{WorkOS::Util.encode_path(provider)}/token", auth: true, body: body, 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 |
#get_data_integration(slug:, request_options: {}) ⇒ WorkOS::DataIntegration
Get a data integration
105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/workos/pipes.rb', line 105 def get_data_integration( slug:, request_options: {} ) response = @client.request( method: :get, path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}", auth: true, request_options: ) result = WorkOS::DataIntegration.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 |
#get_user_connected_account(user_id:, slug:, organization_id: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount
Get a connected account
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'lib/workos/pipes.rb', line 301 def get_user_connected_account( 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: ) 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_data_integrations(before: nil, after: nil, limit: 10, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::DataIntegration>
List data integrations
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/workos/pipes.rb', line 20 def list_data_integrations( before: nil, after: nil, limit: 10, order: "desc", request_options: {} ) params = { "before" => before, "after" => after, "limit" => limit, "order" => order }.compact response = @client.request( method: :get, path: "/data-integrations", auth: true, params: params, request_options: ) fetch_next = ->(cursor) { list_data_integrations( before: before, after: cursor, limit: limit, order: order, request_options: ) } WorkOS::Types::ListStruct.from_response( response, model: WorkOS::DataIntegration, filters: {before: before, limit: limit, order: order}, fetch_next: fetch_next ) end |
#list_user_data_providers(user_id:, organization_id: nil, request_options: {}) ⇒ WorkOS::DataIntegrationsListResponse
List providers for a user
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
# File 'lib/workos/pipes.rb', line 442 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: ) 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 |
#update_data_integration(slug:, description: WorkOS::OMIT, enabled: nil, scopes: WorkOS::OMIT, credentials: nil, api_key: nil, custom_provider: nil, request_options: {}) ⇒ WorkOS::DataIntegration
Update a data integration
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/workos/pipes.rb', line 130 def update_data_integration( slug:, description: WorkOS::OMIT, enabled: nil, scopes: WorkOS::OMIT, credentials: nil, api_key: nil, custom_provider: nil, request_options: {} ) body = { "enabled" => enabled, "credentials" => credentials, "api_key" => api_key, "custom_provider" => custom_provider }.compact body["description"] = description unless description.equal?(WorkOS::OMIT) body["scopes"] = scopes unless scopes.equal?(WorkOS::OMIT) response = @client.request( method: :put, path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}", auth: true, body: body, request_options: ) result = WorkOS::DataIntegration.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 |
#update_data_integration_api_key(slug:, user_id:, secret:, organization_id: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount
Upsert an API key for a connected account
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/workos/pipes.rb', line 184 def update_data_integration_api_key( slug:, user_id:, secret:, organization_id: nil, request_options: {} ) body = { "user_id" => user_id, "organization_id" => organization_id, "secret" => secret }.compact response = @client.request( method: :put, path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}/api-key", auth: true, body: body, 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 |
#update_user_connected_account(user_id:, slug:, access_token: nil, refresh_token: nil, expires_at: nil, scopes: nil, state: nil, organization_id: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount
Update a connected account
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 |
# File 'lib/workos/pipes.rb', line 378 def update_user_connected_account( user_id:, slug:, access_token: nil, refresh_token: nil, expires_at: nil, scopes: nil, state: nil, organization_id: nil, request_options: {} ) params = { "organization_id" => organization_id }.compact body = { "access_token" => access_token, "refresh_token" => refresh_token, "expires_at" => expires_at, "scopes" => scopes, "state" => state }.compact response = @client.request( method: :put, path: "/user_management/users/#{WorkOS::Util.encode_path(user_id)}/connected_accounts/#{WorkOS::Util.encode_path(slug)}", auth: true, params: params, body: body, 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 |