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, 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, 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, uses_pkce: WorkOS::OMIT, is_first_party: nil, organization_id: WorkOS::OMIT, request_options: {}) ⇒ WorkOS::ConnectApplication
Create a Connect Application
105 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 |
# File 'lib/workos/connect.rb', line 105 def create_application( name:, application_type:, description: WorkOS::OMIT, scopes: WorkOS::OMIT, redirect_uris: 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["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
301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
# File 'lib/workos/connect.rb', line 301 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.
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/workos/connect.rb', line 185 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.
148 149 150 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 |
# File 'lib/workos/connect.rb', line 148 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
266 267 268 269 270 271 272 273 274 275 276 277 |
# File 'lib/workos/connect.rb', line 266 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
320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'lib/workos/connect.rb', line 320 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
213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/workos/connect.rb', line 213 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
283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/workos/connect.rb', line 283 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, request_options: {}) ⇒ WorkOS::ConnectApplication
Update a Connect Application
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/workos/connect.rb', line 236 def update_application( id:, name: nil, description: WorkOS::OMIT, scopes: WorkOS::OMIT, redirect_uris: 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) 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 |