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, config: nil, request_options: {}) ⇒ WorkOS::DataIntegrationAuthorizeUrlResponse
Get authorization URL.
-
#create_data_integration(provider:, description: WorkOS::OMIT, enabled: nil, scopes: WorkOS::OMIT, auth_methods: nil, config: 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_data_integration_client_credentials(slug:, user_id:, client_id:, client_secret:, organization_id: nil, config: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount
Upsert client credentials 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, config: nil, request_options: {}) ⇒ WorkOS::DataIntegrationAuthorizeUrlResponse
Get authorization URL
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/workos/pipes.rb', line 219 def ( slug:, user_id:, organization_id: nil, return_to: nil, config: nil, request_options: {} ) body = { "user_id" => user_id, "organization_id" => organization_id, "return_to" => return_to, "config" => config }.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, config: nil, credentials: nil, api_key: nil, custom_provider: nil, request_options: {}) ⇒ WorkOS::DataIntegration
Create a data integration
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 100 101 102 |
# File 'lib/workos/pipes.rb', line 69 def create_data_integration( provider:, description: WorkOS::OMIT, enabled: nil, scopes: WorkOS::OMIT, auth_methods: nil, config: nil, credentials: nil, api_key: nil, custom_provider: nil, request_options: {} ) body = { "provider" => provider, "enabled" => enabled, "auth_methods" => auth_methods, "config" => config, "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
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
# File 'lib/workos/pipes.rb', line 288 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
376 377 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 |
# File 'lib/workos/pipes.rb', line 376 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
167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/workos/pipes.rb', line 167 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
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
# File 'lib/workos/pipes.rb', line 461 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
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/workos/pipes.rb', line 316 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
108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/workos/pipes.rb', line 108 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
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 |
# File 'lib/workos/pipes.rb', line 344 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
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 |
# File 'lib/workos/pipes.rb', line 485 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
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 159 160 161 |
# File 'lib/workos/pipes.rb', line 133 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
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/workos/pipes.rb', line 187 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_data_integration_client_credentials(slug:, user_id:, client_id:, client_secret:, organization_id: nil, config: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount
Upsert client credentials for a connected account
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/workos/pipes.rb', line 254 def update_data_integration_client_credentials( slug:, user_id:, client_id:, client_secret:, organization_id: nil, config: nil, request_options: {} ) body = { "user_id" => user_id, "organization_id" => organization_id, "client_id" => client_id, "client_secret" => client_secret, "config" => config }.compact response = @client.request( method: :put, path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}/client-credentials", 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
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 |
# File 'lib/workos/pipes.rb', line 421 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 |