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: WorkOS::OMIT, 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: 10, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::UserOrganizationMembershipBaseListData>
List Group members.
-
#list_organization_groups(organization_id:, before: nil, after: nil, limit: 10, order: "desc", search: nil, request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::Group>
List groups.
-
#update_organization_group(organization_id:, group_id:, name: nil, description: WorkOS::OMIT, 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
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/workos/groups.rb', line 218 def create_group_organization_membership( organization_id:, group_id:, organization_membership_id:, request_options: {} ) body = { "organization_membership_id" => organization_membership_id } 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: WorkOS::OMIT, request_options: {}) ⇒ WorkOS::Group
Create a group
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/workos/groups.rb', line 70 def create_organization_group( organization_id:, name:, description: WorkOS::OMIT, request_options: {} ) body = { "name" => name } body["description"] = description unless description.equal?(WorkOS::OMIT) 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
245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/workos/groups.rb', line 245 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
148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/workos/groups.rb', line 148 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
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/workos/groups.rb', line 97 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: 10, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::UserOrganizationMembershipBaseListData>
List Group members
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 207 208 209 210 |
# File 'lib/workos/groups.rb', line 171 def list_group_organization_memberships( organization_id:, group_id:, 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: "/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: 10, order: "desc", search: nil, request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::Group>
List groups
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 59 60 61 62 |
# File 'lib/workos/groups.rb', line 22 def list_organization_groups( organization_id:, before: nil, after: nil, limit: 10, order: "desc", search: nil, request_options: {} ) params = { "before" => before, "after" => after, "limit" => limit, "order" => order, "search" => search }.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, search: search, request_options: ) } WorkOS::Types::ListStruct.from_response( response, model: WorkOS::Group, filters: {organization_id: organization_id, before: before, limit: limit, order: order, search: search}, fetch_next: fetch_next ) end |
#update_organization_group(organization_id:, group_id:, name: nil, description: WorkOS::OMIT, request_options: {}) ⇒ WorkOS::Group
Update a group
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/workos/groups.rb', line 120 def update_organization_group( organization_id:, group_id:, name: nil, description: WorkOS::OMIT, request_options: {} ) body = { "name" => name }.compact body["description"] = description unless description.equal?(WorkOS::OMIT) 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 |