# LINE Messaging API
# This document describes LINE Messaging API.
#
# The version of the OpenAPI document: 0.0.1
#
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
# https://openapi-generator.tech
# Do not edit the class manually.

require 'json'

require 'line/bot/v2/http_client'
require 'line/bot/v2/reserved_words'
require 'line/bot/v2/utils'

module Line
  module Bot
    module V2
      module MessagingApi
        class ApiBlobClient
          # Initializes a new {Line::Bot::V2::MessagingApi::ApiBlobClient} instance.
          #
          # @param base_url [String] The base URL for requests (optional).
          #   Defaults to 'https://api-data.line.me' if none is provided.
          #   You can override this for testing or to use a mock server.
          # @param channel_access_token [String] The channel access token for authorization.
          # @param http_options [Hash] HTTP options (same as Net::HTTP options).
          #   See: https://docs.ruby-lang.org/en/3.4/Net/HTTP.html to understand the options.
          #
          # @example
          #   @client ||= Line::Bot::V2::MessagingApi::ApiBlobClient.new(
          #     channel_access_token: "YOUR_CHANNEL_ACCESS_TOKEN",
          #     http_options: {
          #       open_timeout: 5,
          #       read_timeout: 5,
          #     }
          #   )
          def initialize(base_url: nil, channel_access_token:, http_options: {})
            @http_client = HttpClient.new(
              base_url: base_url || 'https://api-data.line.me',
              http_headers: {
                Authorization: "Bearer #{channel_access_token}"
              },
              http_options: http_options
            )
          end

          # Download image, video, and audio data sent from users.
          # This requests to <code>GET https://api-data.line.me/v2/bot/message/{messageId}/content</code>
          # This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.
          #
          # @param message_id [String] Message ID of video or audio
          # @see https://developers.line.biz/en/reference/messaging-api/#get-content
          # @return [Array((String|nil), Integer, Hash{String => String})] when HTTP status code is 200
          # @return [Array((String|nil), Integer, Hash{String => String})] when other HTTP status code is returned. String is HTTP response body itself.
          def get_message_content_with_http_info( # steep:ignore MethodBodyTypeMismatch 
            message_id:
          )
            path = "/v2/bot/message/{messageId}/content"
              .gsub(/{messageId}/, message_id.to_s)

            response = @http_client.get(
              path: path,
            )

            case response.code.to_i
            when 200
              [response.body, 200, response.each_header.to_h]
            else
              [response.body, response.code.to_i, response.each_header.to_h]
            end
          end

          # Download image, video, and audio data sent from users.
          # This requests to <code>GET https://api-data.line.me/v2/bot/message/{messageId}/content</code>
          # When you want to get HTTP status code or response headers, use {#get_message_content_with_http_info} instead of this.
          #
          # @param message_id [String] Message ID of video or audio
          # @see https://developers.line.biz/en/reference/messaging-api/#get-content
          # @return [String, nil] when HTTP status code is 200
          # @return [String, nil] when other HTTP status code is returned. This String is HTTP response body itself.
          def get_message_content(
            message_id:
          )
            response_body, _status_code, _headers = get_message_content_with_http_info(
              message_id: message_id
            )

            response_body
          end

          # Get a preview image of the image or video
          # This requests to <code>GET https://api-data.line.me/v2/bot/message/{messageId}/content/preview</code>
          # This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.
          #
          # @param message_id [String] Message ID of image or video
          # @see https://developers.line.biz/en/reference/messaging-api/#get-image-or-video-preview
          # @return [Array((String|nil), Integer, Hash{String => String})] when HTTP status code is 200
          # @return [Array((String|nil), Integer, Hash{String => String})] when other HTTP status code is returned. String is HTTP response body itself.
          def get_message_content_preview_with_http_info( # steep:ignore MethodBodyTypeMismatch 
            message_id:
          )
            path = "/v2/bot/message/{messageId}/content/preview"
              .gsub(/{messageId}/, message_id.to_s)

            response = @http_client.get(
              path: path,
            )

            case response.code.to_i
            when 200
              [response.body, 200, response.each_header.to_h]
            else
              [response.body, response.code.to_i, response.each_header.to_h]
            end
          end

          # Get a preview image of the image or video
          # This requests to <code>GET https://api-data.line.me/v2/bot/message/{messageId}/content/preview</code>
          # When you want to get HTTP status code or response headers, use {#get_message_content_preview_with_http_info} instead of this.
          #
          # @param message_id [String] Message ID of image or video
          # @see https://developers.line.biz/en/reference/messaging-api/#get-image-or-video-preview
          # @return [String, nil] when HTTP status code is 200
          # @return [String, nil] when other HTTP status code is returned. This String is HTTP response body itself.
          def get_message_content_preview(
            message_id:
          )
            response_body, _status_code, _headers = get_message_content_preview_with_http_info(
              message_id: message_id
            )

            response_body
          end

          # Verify the preparation status of a video or audio for getting
          # This requests to <code>GET https://api-data.line.me/v2/bot/message/{messageId}/content/transcoding</code>
          # This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.
          #
          # @param message_id [String] Message ID of video or audio
          # @see https://developers.line.biz/en/reference/messaging-api/#verify-video-or-audio-preparation-status
          # @return [Array(Line::Bot::V2::MessagingApi::GetMessageContentTranscodingResponse, Integer, Hash{String => String})] when HTTP status code is 200
          # @return [Array((String|nil), Integer, Hash{String => String})] when other HTTP status code is returned. String is HTTP response body itself.
          def get_message_content_transcoding_by_message_id_with_http_info( # steep:ignore MethodBodyTypeMismatch 
            message_id:
          )
            path = "/v2/bot/message/{messageId}/content/transcoding"
              .gsub(/{messageId}/, message_id.to_s)

            response = @http_client.get(
              path: path,
            )

            case response.code.to_i
            when 200
              json = Line::Bot::V2::Utils.deep_underscore(JSON.parse(response.body))
              json.transform_keys! do |key|
                Line::Bot::V2::RESERVED_WORDS.include?(key) ? "_#{key}".to_sym : key
              end
              response_body = Line::Bot::V2::MessagingApi::GetMessageContentTranscodingResponse.create(json) # steep:ignore InsufficientKeywordArguments
              [response_body, 200, response.each_header.to_h]
            else
              [response.body, response.code.to_i, response.each_header.to_h]
            end
          end

          # Verify the preparation status of a video or audio for getting
          # This requests to <code>GET https://api-data.line.me/v2/bot/message/{messageId}/content/transcoding</code>
          # When you want to get HTTP status code or response headers, use {#get_message_content_transcoding_by_message_id_with_http_info} instead of this.
          #
          # @param message_id [String] Message ID of video or audio
          # @see https://developers.line.biz/en/reference/messaging-api/#verify-video-or-audio-preparation-status
          # @return [Line::Bot::V2::MessagingApi::GetMessageContentTranscodingResponse] when HTTP status code is 200
          # @return [String, nil] when other HTTP status code is returned. This String is HTTP response body itself.
          def get_message_content_transcoding_by_message_id(
            message_id:
          )
            response_body, _status_code, _headers = get_message_content_transcoding_by_message_id_with_http_info(
              message_id: message_id
            )

            response_body
          end

          # Download rich menu image.
          # This requests to <code>GET https://api-data.line.me/v2/bot/richmenu/{richMenuId}/content</code>
          # This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.
          #
          # @param rich_menu_id [String] ID of the rich menu with the image to be downloaded
          # @see https://developers.line.biz/en/reference/messaging-api/#download-rich-menu-image
          # @return [Array((String|nil), Integer, Hash{String => String})] when HTTP status code is 200
          # @return [Array((String|nil), Integer, Hash{String => String})] when other HTTP status code is returned. String is HTTP response body itself.
          def get_rich_menu_image_with_http_info( # steep:ignore MethodBodyTypeMismatch 
            rich_menu_id:
          )
            path = "/v2/bot/richmenu/{richMenuId}/content"
              .gsub(/{richMenuId}/, rich_menu_id.to_s)

            response = @http_client.get(
              path: path,
            )

            case response.code.to_i
            when 200
              [response.body, 200, response.each_header.to_h]
            else
              [response.body, response.code.to_i, response.each_header.to_h]
            end
          end

          # Download rich menu image.
          # This requests to <code>GET https://api-data.line.me/v2/bot/richmenu/{richMenuId}/content</code>
          # When you want to get HTTP status code or response headers, use {#get_rich_menu_image_with_http_info} instead of this.
          #
          # @param rich_menu_id [String] ID of the rich menu with the image to be downloaded
          # @see https://developers.line.biz/en/reference/messaging-api/#download-rich-menu-image
          # @return [String, nil] when HTTP status code is 200
          # @return [String, nil] when other HTTP status code is returned. This String is HTTP response body itself.
          def get_rich_menu_image(
            rich_menu_id:
          )
            response_body, _status_code, _headers = get_rich_menu_image_with_http_info(
              rich_menu_id: rich_menu_id
            )

            response_body
          end

          # Upload rich menu image
          # This requests to <code>POST https://api-data.line.me/v2/bot/richmenu/{richMenuId}/content</code>
          # This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.
          #
          # @param rich_menu_id [String] The ID of the rich menu to attach the image to
          # @param body [File, nil] 
          # @see https://developers.line.biz/en/reference/messaging-api/#upload-rich-menu-image
          # @return [Array((String|nil), Integer, Hash{String => String})] when HTTP status code is 200
          # @return [Array((String|nil), Integer, Hash{String => String})] when other HTTP status code is returned. String is HTTP response body itself.
          def set_rich_menu_image_with_http_info( # steep:ignore MethodBodyTypeMismatch 
            rich_menu_id:, 
            body: nil
          )
            path = "/v2/bot/richmenu/{richMenuId}/content"
              .gsub(/{richMenuId}/, rich_menu_id.to_s)

            response = @http_client.post(
              path: path,
              body_params: body,
            )

            case response.code.to_i
            when 200
              [response.body, 200, response.each_header.to_h]
            else
              [response.body, response.code.to_i, response.each_header.to_h]
            end
          end

          # Upload rich menu image
          # This requests to <code>POST https://api-data.line.me/v2/bot/richmenu/{richMenuId}/content</code>
          # When you want to get HTTP status code or response headers, use {#set_rich_menu_image_with_http_info} instead of this.
          #
          # @param rich_menu_id [String] The ID of the rich menu to attach the image to
          # @param body [File, nil] 
          # @see https://developers.line.biz/en/reference/messaging-api/#upload-rich-menu-image
          # @return [String, nil] when HTTP status code is 200
          # @return [String, nil] when other HTTP status code is returned. This String is HTTP response body itself.
          def set_rich_menu_image(
            rich_menu_id:,
            body: nil
          )
            response_body, _status_code, _headers = set_rich_menu_image_with_http_info(
              rich_menu_id: rich_menu_id,
              body: body
            )

            response_body
          end
        end
      end
    end
  end
end
