lib/square/api/catalog_api.rb
# Uploads a new image file to replace the existing one in the specified
# [CatalogImage]($m/CatalogImage) object.
# This `UpdateCatalogImage` endpoint accepts HTTP multipart/form-data
# requests with a JSON part and an image file part in
# JPEG, PJPEG, PNG, or GIF format. The maximum file size is 15MB.
# @param [String] image_id Required parameter: The ID of the `CatalogImage`
# object to update the encapsulated image file.
# @param [UpdateCatalogImageRequest] request Optional parameter: Example:
# @param [File | UploadIO] image_file Optional parameter: Example:
# @return [UpdateCatalogImageResponse Hash] response from the API call
Uploads a new image file to replace the existing one in the specified
[CatalogImage]($m/CatalogImage) object.
This `UpdateCatalogImage` endpoint accepts HTTP multipart/form-data
requests with a JSON part and an image file part in
JPEG, PJPEG, PNG, or GIF format. The maximum file size is 15MB.
Uploads a new image file to replace the existing one in the specified [ CatalogImage ] ( $m / CatalogImage ) object . This ` UpdateCatalogImage ` endpoint accepts HTTP multipart / form - data requests with a JSON part and an image file part in JPEG PJPEG PNG or GIF format . The maximum file size is 15MB .
def update_catalog_image(image_id:,
                             request: nil,
                             image_file: nil)
      _query_builder = config.get_base_uri
      _query_builder << '/v2/catalog/images/{image_id}'
      _query_builder = APIHelper.append_url_with_template_parameters(
        _query_builder,
        'image_id' => { 'value' => image_id, 'encode' => true }
      )
      _query_url = APIHelper.clean_url _query_builder
      if image_file.is_a? FileWrapper
        image_file_wrapper = image_file.file
        image_file_content_type = image_file.content_type
      else
        image_file_wrapper = image_file
        image_file_content_type = 'image/jpeg'
      end
      _headers = {
        'accept' => 'application/json'
      }
      _parameters = {
        'request' => Faraday::UploadIO.new(
          StringIO.new(request.to_json),
          'application/json'
        ),
        'image_file' => Faraday::UploadIO.new(
          image_file_wrapper,
          image_file_content_type
        )
      }
      _parameters = APIHelper.form_encode_parameters(_parameters)
      _request = config.http_client.put(
        _query_url,
        headers: _headers,
        parameters: _parameters
      )
      OAuth2.apply(config, _request)
      _response = execute_request(_request)
      decoded = APIHelper.json_deserialize(_response.raw_body)
      _errors = APIHelper.map_response(decoded, ['errors'])
      ApiResponse.new(
        _response, data: decoded, errors: _errors
      )
    end
def update_catalog_image ( image_id : , request : nil , image_file : nil ) _query_builder = config . get_base_uri _query_builder << '/v2/catalog/images/{image_id}' _query_builder = APIHelper . append_url_with_template_parameters ( _query_builder , 'image_id' => { 'value' => image_id , 'encode' => true } ) _query_url = APIHelper . clean_url _query_builder if image_file . is_a? FileWrapper image_file_wrapper = image_file . file image_file_content_type = image_file . content_type else image_file_wrapper = image_file image_file_content_type = 'image/jpeg' end _headers = { 'accept' => 'application/json' } _parameters = { 'request' => Faraday :: UploadIO . new ( StringIO . new ( request . to_json ) , 'application/json' ) , 'image_file' => Faraday :: UploadIO . new ( image_file_wrapper , image_file_content_type ) } _parameters = APIHelper . form_encode_parameters ( _parameters ) _request = config . http_client . put ( _query_url , headers : _headers , parameters : _parameters ) OAuth2 . apply ( config , _request ) _response = execute_request ( _request ) decoded = APIHelper . json_deserialize ( _response . raw_body ) _errors = APIHelper . map_response ( decoded , [ 'errors' ] ) ApiResponse . new ( _response , data : decoded , errors : _errors ) end
Uploads a new image file to replace the existing one in the specified
[CatalogImage]($m/CatalogImage) object.
Uploads a new image file to replace the existing one in the specified [ CatalogImage ] ( $m / CatalogImage ) object .
# Prepare query url. # Prepare headers. # Prepare form parameters. # Prepare and execute HttpRequest. # Return appropriate response type.
response from the API call
response from the API call
UpdateCatalogImageResponse Hash
image_id
<not_specific>
request
<not_specific>
image_file
<not_specific>
<not_specific>
image_file Optional parameter: Example.
image_file Optional parameter : Example .