Class: Appwrite::Presences
- Defined in:
- lib/appwrite/services/presences.rb
Instance Method Summary collapse
-
#delete(presence_id:) ⇒ Object
Delete a presence log by its unique ID.
-
#get(presence_id:) ⇒ Presence
Get a presence log by its unique ID.
-
#initialize(client) ⇒ Presences
constructor
A new instance of Presences.
-
#list(queries: nil, total: nil, ttl: nil) ⇒ PresenceList
List presence logs.
-
#update(presence_id:, user_id:, status: nil, expires_at: nil, metadata: nil, permissions: nil, purge: nil) ⇒ Presence
Update a presence log by its unique ID.
-
#upsert(presence_id:, user_id:, status:, permissions: nil, expires_at: nil, metadata: nil) ⇒ Presence
Create or update a presence log by its user ID.
Constructor Details
#initialize(client) ⇒ Presences
Returns a new instance of Presences.
6 7 8 |
# File 'lib/appwrite/services/presences.rb', line 6 def initialize(client) @client = client end |
Instance Method Details
#delete(presence_id:) ⇒ Object
Delete a presence log by its unique ID.
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/appwrite/services/presences.rb', line 182 def delete(presence_id:) api_path = '/presences/{presenceId}' .gsub('{presenceId}', presence_id) if presence_id.nil? raise Appwrite::Exception.new('Missing required parameter: "presenceId"') end api_params = { } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', } @client.call( method: 'DELETE', path: api_path, headers: api_headers, params: api_params, ) end |
#get(presence_id:) ⇒ Presence
Get a presence log by its unique ID. Entries whose expiresAt is in the
past are treated as not found.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/appwrite/services/presences.rb', line 49 def get(presence_id:) api_path = '/presences/{presenceId}' .gsub('{presenceId}', presence_id) if presence_id.nil? raise Appwrite::Exception.new('Missing required parameter: "presenceId"') end api_params = { } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "accept": 'application/json', } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, response_type: Models::Presence ) end |
#list(queries: nil, total: nil, ttl: nil) ⇒ PresenceList
List presence logs. Expired entries are filtered out automatically.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/appwrite/services/presences.rb', line 18 def list(queries: nil, total: nil, ttl: nil) api_path = '/presences' api_params = { queries: queries, total: total, ttl: ttl, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "accept": 'application/json', } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, response_type: Models::PresenceList ) end |
#update(presence_id:, user_id:, status: nil, expires_at: nil, metadata: nil, permissions: nil, purge: nil) ⇒ Presence
Update a presence log by its unique ID. Using the patch method you can pass only specific fields that will get updated.
139 140 141 142 143 144 145 146 147 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 |
# File 'lib/appwrite/services/presences.rb', line 139 def update(presence_id:, user_id:, status: nil, expires_at: nil, metadata: nil, permissions: nil, purge: nil) api_path = '/presences/{presenceId}' .gsub('{presenceId}', presence_id) if presence_id.nil? raise Appwrite::Exception.new('Missing required parameter: "presenceId"') end if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end api_params = { userId: user_id, status: status, expiresAt: expires_at, metadata: , permissions: , purge: purge, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'PATCH', path: api_path, headers: api_headers, params: api_params, response_type: Models::Presence ) end |
#upsert(presence_id:, user_id:, status:, permissions: nil, expires_at: nil, metadata: nil) ⇒ Presence
Create or update a presence log by its user ID.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/appwrite/services/presences.rb', line 86 def upsert(presence_id:, user_id:, status:, permissions: nil, expires_at: nil, metadata: nil) api_path = '/presences/{presenceId}' .gsub('{presenceId}', presence_id) if presence_id.nil? raise Appwrite::Exception.new('Missing required parameter: "presenceId"') end if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end if status.nil? raise Appwrite::Exception.new('Missing required parameter: "status"') end api_params = { userId: user_id, status: status, permissions: , expiresAt: expires_at, metadata: , } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'PUT', path: api_path, headers: api_headers, params: api_params, response_type: Models::Presence ) end |