169169#
170170# @return [String]
171171#
172- def generate_secured_api_key(parent_api_key, restrictions = { } )
172+ def self. generate_secured_api_key(parent_api_key, restrictions = { } )
173173 restrictions = restrictions.to_hash
174174 if restrictions.key?(:searchParams)
175175 # merge searchParams with the root of the restrictions
@@ -186,13 +186,25 @@ def generate_secured_api_key(parent_api_key, restrictions = {})
186186 Base64.encode64("#{ hmac} #{ url_encoded_restrictions} ").gsub("\n", '')
187187end
188188
189+ # Helper: Generates a secured API key based on the given `parent_api_key` and given `restrictions`.
190+ #
191+ # @param parent_api_key [String] Parent API key used the generate the secured key
192+ # @param restrictions [SecuredApiKeyRestrictions] Restrictions to apply on the secured key
193+ #
194+ # @return [String]
195+ #
196+ def generate_secured_api_key(parent_api_key, restrictions = { } )
197+ self.class.generate_secured_api_key(parent_api_key, restrictions)
198+ end
199+
200+
189201# Helper: Retrieves the remaining validity of the previous generated `secured_api_key`, the `validUntil` parameter must have been provided.
190202#
191203# @param secured_api_key [String]
192204#
193205# @return [Integer]
194206#
195- def get_secured_api_key_remaining_validity(secured_api_key)
207+ def self. get_secured_api_key_remaining_validity(secured_api_key)
196208 now = Time.now.to_i
197209 decoded_key = Base64.decode64(secured_api_key)
198210 regex = 'validUntil=(\d+)'
@@ -207,6 +219,16 @@ def get_secured_api_key_remaining_validity(secured_api_key)
207219 valid_until - now
208220end
209221
222+ # Helper: Retrieves the remaining validity of the previous generated `secured_api_key`, the `validUntil` parameter must have been provided.
223+ #
224+ # @param secured_api_key [String]
225+ #
226+ # @return [Integer]
227+ #
228+ def get_secured_api_key_remaining_validity(secured_api_key)
229+ self.class.get_secured_api_key_remaining_validity(secured_api_key)
230+ end
231+
210232# Helper: Saves the given array of objects in the given index. The `chunked_batch` helper is used under the hood, which creates a `batch` requests with at most 1000 objects in it.
211233#
212234# @param index_name [String]: The `index_name` to save `objects` in.
0 commit comments