Method: Appwrite::Avatars#get_flag

Defined in:
lib/appwrite/services/avatars.rb

#get_flag(code:, width: nil, height: nil, quality: nil) ⇒ Object

You can use this endpoint to show different country flags icons to your users. The code argument receives the 2 letter country code. Use width, height and quality arguments to change the output settings. Country codes follow the ISO 3166-1 standard.

When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px.

Parameters:

  • code (Flag)

    Country Code. ISO Alpha-2 country code format.

  • width (Integer) (defaults to: nil)

    Image width. Pass an integer between 0 to 2000. Defaults to 100.

  • height (Integer) (defaults to: nil)

    Image height. Pass an integer between 0 to 2000. Defaults to 100.

  • quality (Integer) (defaults to: nil)

    Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.

Returns:

  • []



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/appwrite/services/avatars.rb', line 140

def get_flag(code:, width: nil, height: nil, quality: nil)
    api_path = '/avatars/flags/{code}'
        .gsub('{code}', code)

    if code.nil?
      raise Appwrite::Exception.new('Missing required parameter: "code"')
    end

    api_params = {
        width: width,
        height: height,
        quality: quality,
    }
    
    api_headers = {
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
    )
end