Class: WorkOS::Connect
- Inherits:
-
Object
- Object
- WorkOS::Connect
- Defined in:
- lib/workos/connect.rb
Instance Method Summary collapse
-
#complete_oauth2(external_auth_id:, user:, user_consent_options: nil, request_options: {}) ⇒ WorkOS::ExternalAuthCompleteResponse
Complete external authentication.
-
#create_application(name:, application_type:, description: WorkOS::OMIT, scopes: WorkOS::OMIT, redirect_uris: WorkOS::OMIT, cors_origins: WorkOS::OMIT, uses_pkce: WorkOS::OMIT, is_first_party: nil, organization_id: WorkOS::OMIT, request_options: {}) ⇒ WorkOS::ConnectApplication
Create a Connect Application.
-
#create_application_client_secret(id:, request_options: {}) ⇒ WorkOS::NewConnectApplicationSecret
Create a new client secret for a Connect Application.
-
#create_m2m_application(name:, organization_id:, description: nil, scopes: nil, request_options: {}) ⇒ WorkOS::ConnectApplication
Create M2M application.
-
#create_oauth_application(name:, is_first_party:, description: nil, scopes: nil, redirect_uris: nil, uses_pkce: nil, organization_id: nil, request_options: {}) ⇒ WorkOS::ConnectApplication
Create OAuth application.
-
#delete_application(id:, request_options: {}) ⇒ void
Delete a Connect Application.
-
#delete_client_secret(id:, request_options: {}) ⇒ void
Delete a Client Secret.
-
#get_application(id:, request_options: {}) ⇒ WorkOS::ConnectApplication
Get a Connect Application.
-
#initialize(client) ⇒ Connect
constructor
A new instance of Connect.
-
#list_application_client_secrets(id:, request_options: {}) ⇒ Array<WorkOS::ApplicationCredentialsListItem>
List Client Secrets for a Connect Application.
-
#list_applications(before: nil, after: nil, limit: 10, order: "desc", registration_types: nil, organization_id: nil, request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::ConnectApplication>
List Connect Applications.
-
#update_application(id:, name: nil, description: WorkOS::OMIT, scopes: WorkOS::OMIT, redirect_uris: WorkOS::OMIT, cors_origins: WorkOS::OMIT, request_options: {}) ⇒ WorkOS::ConnectApplication
Update a Connect Application.
Constructor Details
#initialize(client) ⇒ Connect
Returns a new instance of Connect.
9 10 11 |
# File 'lib/workos/connect.rb', line 9 def initialize(client) @client = client end |
Instance Method Details
#complete_oauth2(external_auth_id:, user:, user_consent_options: nil, request_options: {}) ⇒ WorkOS::ExternalAuthCompleteResponse
Complete external authentication
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/workos/connect.rb', line 19 def complete_oauth2( external_auth_id:, user:, user_consent_options: nil, request_options: {} ) body = { "external_auth_id" => external_auth_id, "user" => user, "user_consent_options" => }.compact response = @client.request( method: :post, path: "/authkit/oauth2/complete", auth: true, body: body, request_options: ) result = WorkOS::ExternalAuthCompleteResponse.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_application(name:, application_type:, description: WorkOS::OMIT, scopes: WorkOS::OMIT, redirect_uris: WorkOS::OMIT, cors_origins: WorkOS::OMIT, uses_pkce: WorkOS::OMIT, is_first_party: nil, organization_id: WorkOS::OMIT, request_options: {}) ⇒ WorkOS::ConnectApplication
Create a Connect Application
106 107 108 109 110 111 112 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 139 |
# File 'lib/workos/connect.rb', line 106 def create_application( name:, application_type:, description: WorkOS::OMIT, scopes: WorkOS::OMIT, redirect_uris: WorkOS::OMIT, cors_origins: WorkOS::OMIT, uses_pkce: WorkOS::OMIT, is_first_party: nil, organization_id: WorkOS::OMIT, request_options: {} ) body = { "name" => name, "application_type" => application_type, "is_first_party" => is_first_party }.compact body["description"] = description unless description.equal?(WorkOS::OMIT) body["scopes"] = scopes unless scopes.equal?(WorkOS::OMIT) body["redirect_uris"] = redirect_uris unless redirect_uris.equal?(WorkOS::OMIT) body["cors_origins"] = cors_origins unless cors_origins.equal?(WorkOS::OMIT) body["uses_pkce"] = uses_pkce unless uses_pkce.equal?(WorkOS::OMIT) body["organization_id"] = organization_id unless organization_id.equal?(WorkOS::OMIT) response = @client.request( method: :post, path: "/connect/applications", auth: true, body: body, request_options: ) result = WorkOS::ConnectApplication.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_application_client_secret(id:, request_options: {}) ⇒ WorkOS::NewConnectApplicationSecret
Create a new client secret for a Connect Application
307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'lib/workos/connect.rb', line 307 def create_application_client_secret( id:, request_options: {} ) response = @client.request( method: :post, path: "/connect/applications/#{WorkOS::Util.encode_path(id)}/client_secrets", auth: true, request_options: ) result = WorkOS::NewConnectApplicationSecret.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_m2m_application(name:, organization_id:, description: nil, scopes: nil, request_options: {}) ⇒ WorkOS::ConnectApplication
Create M2M application.
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/workos/connect.rb', line 188 def create_m2m_application( name:, organization_id:, description: nil, scopes: nil, request_options: {} ) body = { "application_type" => "m2m", "name" => name, "organization_id" => organization_id, "description" => description, "scopes" => scopes }.compact response = @client.request( method: :post, path: "/connect/applications", auth: true, body: body, request_options: ) WorkOS::ConnectApplication.new(response.body) end |
#create_oauth_application(name:, is_first_party:, description: nil, scopes: nil, redirect_uris: nil, uses_pkce: nil, organization_id: nil, request_options: {}) ⇒ WorkOS::ConnectApplication
Create OAuth application.
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/workos/connect.rb', line 151 def create_oauth_application( name:, is_first_party:, description: nil, scopes: nil, redirect_uris: nil, uses_pkce: nil, organization_id: nil, request_options: {} ) body = { "application_type" => "oauth", "name" => name, "is_first_party" => is_first_party, "description" => description, "scopes" => scopes, "redirect_uris" => redirect_uris, "uses_pkce" => uses_pkce, "organization_id" => organization_id }.compact response = @client.request( method: :post, path: "/connect/applications", auth: true, body: body, request_options: ) WorkOS::ConnectApplication.new(response.body) end |
#delete_application(id:, request_options: {}) ⇒ void
This method returns an undefined value.
Delete a Connect Application
272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/workos/connect.rb', line 272 def delete_application( id:, request_options: {} ) @client.request( method: :delete, path: "/connect/applications/#{WorkOS::Util.encode_path(id)}", auth: true, request_options: ) nil end |
#delete_client_secret(id:, request_options: {}) ⇒ void
This method returns an undefined value.
Delete a Client Secret
326 327 328 329 330 331 332 333 334 335 336 337 |
# File 'lib/workos/connect.rb', line 326 def delete_client_secret( id:, request_options: {} ) @client.request( method: :delete, path: "/connect/client_secrets/#{WorkOS::Util.encode_path(id)}", auth: true, request_options: ) nil end |
#get_application(id:, request_options: {}) ⇒ WorkOS::ConnectApplication
Get a Connect Application
216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/workos/connect.rb', line 216 def get_application( id:, request_options: {} ) response = @client.request( method: :get, path: "/connect/applications/#{WorkOS::Util.encode_path(id)}", auth: true, request_options: ) result = WorkOS::ConnectApplication.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_application_client_secrets(id:, request_options: {}) ⇒ Array<WorkOS::ApplicationCredentialsListItem>
List Client Secrets for a Connect Application
289 290 291 292 293 294 295 296 297 298 299 300 301 |
# File 'lib/workos/connect.rb', line 289 def list_application_client_secrets( id:, request_options: {} ) response = @client.request( method: :get, path: "/connect/applications/#{WorkOS::Util.encode_path(id)}/client_secrets", auth: true, request_options: ) parsed = JSON.parse(response.body) (parsed || []).map { |item| WorkOS::ApplicationCredentialsListItem.new(item) } end |
#list_applications(before: nil, after: nil, limit: 10, order: "desc", registration_types: nil, organization_id: nil, request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::ConnectApplication>
List Connect Applications
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 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 |
# File 'lib/workos/connect.rb', line 51 def list_applications( before: nil, after: nil, limit: 10, order: "desc", registration_types: nil, organization_id: nil, request_options: {} ) params = { "before" => before, "after" => after, "limit" => limit, "order" => order, "registration_types" => registration_types, "organization_id" => organization_id }.compact response = @client.request( method: :get, path: "/connect/applications", auth: true, params: params, request_options: ) fetch_next = ->(cursor) { list_applications( before: before, after: cursor, limit: limit, order: order, registration_types: registration_types, organization_id: organization_id, request_options: ) } WorkOS::Types::ListStruct.from_response( response, model: WorkOS::ConnectApplication, filters: {before: before, limit: limit, order: order, registration_types: registration_types, organization_id: organization_id}, fetch_next: fetch_next ) end |
#update_application(id:, name: nil, description: WorkOS::OMIT, scopes: WorkOS::OMIT, redirect_uris: WorkOS::OMIT, cors_origins: WorkOS::OMIT, request_options: {}) ⇒ WorkOS::ConnectApplication
Update a Connect Application
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/workos/connect.rb', line 240 def update_application( id:, name: nil, description: WorkOS::OMIT, scopes: WorkOS::OMIT, redirect_uris: WorkOS::OMIT, cors_origins: WorkOS::OMIT, request_options: {} ) body = { "name" => name }.compact body["description"] = description unless description.equal?(WorkOS::OMIT) body["scopes"] = scopes unless scopes.equal?(WorkOS::OMIT) body["redirect_uris"] = redirect_uris unless redirect_uris.equal?(WorkOS::OMIT) body["cors_origins"] = cors_origins unless cors_origins.equal?(WorkOS::OMIT) response = @client.request( method: :put, path: "/connect/applications/#{WorkOS::Util.encode_path(id)}", auth: true, body: body, request_options: ) result = WorkOS::ConnectApplication.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 |