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(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.
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/appwrite/services/presences.rb', line 174 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 = { "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.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/appwrite/services/presences.rb', line 47 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 = { } @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 |
# 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 = { } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, response_type: Models::PresenceList ) end |
#update_presence(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.
133 134 135 136 137 138 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 |
# File 'lib/appwrite/services/presences.rb', line 133 def update_presence(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 = { "content-type": '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.
82 83 84 85 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 |
# File 'lib/appwrite/services/presences.rb', line 82 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 = { "content-type": 'application/json', } @client.call( method: 'PUT', path: api_path, headers: api_headers, params: api_params, response_type: Models::Presence ) end |