Class: WorkOS::Groups
- Inherits:
-
Object
- Object
- WorkOS::Groups
- Defined in:
- lib/workos/groups.rb
Instance Method Summary collapse
-
#create_group_organization_membership(organization_id:, group_id:, organization_membership_id:, request_options: {}) ⇒ WorkOS::Group
Add a member to a Group.
-
#create_organization_group(organization_id:, name:, description: nil, request_options: {}) ⇒ WorkOS::Group
Create a group.
-
#delete_group_organization_membership(organization_id:, group_id:, om_id:, request_options: {}) ⇒ void
Remove a member from a Group.
-
#delete_organization_group(organization_id:, group_id:, request_options: {}) ⇒ void
Delete a group.
-
#get_organization_group(organization_id:, group_id:, request_options: {}) ⇒ WorkOS::Group
Get a group.
-
#initialize(client) ⇒ Groups
constructor
A new instance of Groups.
-
#list_group_organization_memberships(organization_id:, group_id:, before: nil, after: nil, limit: nil, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::UserOrganizationMembershipBaseListData>
List Group members.
-
#list_organization_groups(organization_id:, before: nil, after: nil, limit: nil, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::Group>
List groups.
-
#update_organization_group(organization_id:, group_id:, name: nil, description: nil, request_options: {}) ⇒ WorkOS::Group
Update a group.
Constructor Details
#initialize(client) ⇒ Groups
Returns a new instance of Groups.
9 10 11 |
# File 'lib/workos/groups.rb', line 9 def initialize(client) @client = client end |
Instance Method Details
#create_group_organization_membership(organization_id:, group_id:, organization_membership_id:, request_options: {}) ⇒ WorkOS::Group
Add a member to a Group
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/workos/groups.rb', line 214 def create_group_organization_membership( organization_id:, group_id:, organization_membership_id:, request_options: {} ) body = { "organization_membership_id" => organization_membership_id }.compact response = @client.request( method: :post, path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/groups/#{WorkOS::Util.encode_path(group_id)}/organization-memberships", auth: true, body: body, request_options: ) result = WorkOS::Group.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_organization_group(organization_id:, name:, description: nil, request_options: {}) ⇒ WorkOS::Group
Create a group
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/workos/groups.rb', line 66 def create_organization_group( organization_id:, name:, description: nil, request_options: {} ) body = { "name" => name, "description" => description }.compact response = @client.request( method: :post, path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/groups", auth: true, body: body, request_options: ) result = WorkOS::Group.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_group_organization_membership(organization_id:, group_id:, om_id:, request_options: {}) ⇒ void
This method returns an undefined value.
Remove a member from a Group
241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/workos/groups.rb', line 241 def delete_group_organization_membership( organization_id:, group_id:, om_id:, request_options: {} ) @client.request( method: :delete, path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/groups/#{WorkOS::Util.encode_path(group_id)}/organization-memberships/#{WorkOS::Util.encode_path(om_id)}", auth: true, request_options: ) nil end |
#delete_organization_group(organization_id:, group_id:, request_options: {}) ⇒ void
This method returns an undefined value.
Delete a group
144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/workos/groups.rb', line 144 def delete_organization_group( organization_id:, group_id:, request_options: {} ) @client.request( method: :delete, path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/groups/#{WorkOS::Util.encode_path(group_id)}", auth: true, request_options: ) nil end |
#get_organization_group(organization_id:, group_id:, request_options: {}) ⇒ WorkOS::Group
Get a group
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/workos/groups.rb', line 93 def get_organization_group( organization_id:, group_id:, request_options: {} ) response = @client.request( method: :get, path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/groups/#{WorkOS::Util.encode_path(group_id)}", auth: true, request_options: ) result = WorkOS::Group.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_group_organization_memberships(organization_id:, group_id:, before: nil, after: nil, limit: nil, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::UserOrganizationMembershipBaseListData>
List Group members
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 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/groups.rb', line 167 def list_group_organization_memberships( organization_id:, group_id:, before: nil, after: nil, limit: nil, order: "desc", request_options: {} ) params = { "before" => before, "after" => after, "limit" => limit, "order" => order }.compact response = @client.request( method: :get, path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/groups/#{WorkOS::Util.encode_path(group_id)}/organization-memberships", auth: true, params: params, request_options: ) fetch_next = ->(cursor) { list_group_organization_memberships( organization_id: organization_id, group_id: group_id, before: before, after: cursor, limit: limit, order: order, request_options: ) } WorkOS::Types::ListStruct.from_response( response, model: WorkOS::UserOrganizationMembershipBaseListData, filters: {organization_id: organization_id, group_id: group_id, before: before, limit: limit, order: order}, fetch_next: fetch_next ) end |
#list_organization_groups(organization_id:, before: nil, after: nil, limit: nil, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::Group>
List groups
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 56 57 58 |
# File 'lib/workos/groups.rb', line 21 def list_organization_groups( organization_id:, before: nil, after: nil, limit: nil, order: "desc", request_options: {} ) params = { "before" => before, "after" => after, "limit" => limit, "order" => order }.compact response = @client.request( method: :get, path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/groups", auth: true, params: params, request_options: ) fetch_next = ->(cursor) { list_organization_groups( organization_id: organization_id, before: before, after: cursor, limit: limit, order: order, request_options: ) } WorkOS::Types::ListStruct.from_response( response, model: WorkOS::Group, filters: {organization_id: organization_id, before: before, limit: limit, order: order}, fetch_next: fetch_next ) end |
#update_organization_group(organization_id:, group_id:, name: nil, description: nil, request_options: {}) ⇒ WorkOS::Group
Update a group
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/workos/groups.rb', line 116 def update_organization_group( organization_id:, group_id:, name: nil, description: nil, request_options: {} ) body = { "name" => name, "description" => description }.compact response = @client.request( method: :patch, path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/groups/#{WorkOS::Util.encode_path(group_id)}", auth: true, body: body, request_options: ) result = WorkOS::Group.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 |