Class: Line::Bot::V2::MessagingApi::ApiBlobClient

Inherits:
Object
  • Object
show all
Defined in:
lib/line/bot/v2/messaging_api/api/messaging_api_blob_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(base_url: nil, channel_access_token:, http_options: {}) ⇒ ApiBlobClient

Initializes a new Line::Bot::V2::MessagingApi::ApiBlobClient instance.

Examples:

@client ||= Line::Bot::V2::MessagingApi::ApiBlobClient.new(
  channel_access_token: "YOUR_CHANNEL_ACCESS_TOKEN",
  http_options: {
    open_timeout: 5,
    read_timeout: 5,
  }
)

Parameters:

  • base_url (String) (defaults to: nil)

    The base URL for requests (optional). Defaults to ‘api-data.line.me’ if none is provided. You can override this for testing or to use a mock server.

  • channel_access_token (String)

    The channel access token for authorization.

  • http_options (Hash) (defaults to: {})

    HTTP options (same as Net::HTTP options). See: docs.ruby-lang.org/en/3.4/Net/HTTP.html to understand the options.



38
39
40
41
42
43
44
45
46
# File 'lib/line/bot/v2/messaging_api/api/messaging_api_blob_client.rb', line 38

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

Instance Method Details

#get_message_content(message_id:) ⇒ String?

Download image, video, and audio data sent from users. This requests to GET https://api-data.line.me/v2/bot/message/{messageId}/content When you want to get HTTP status code or response headers, use #get_message_content_with_http_info instead of this.

Parameters:

  • message_id (String)

    Message ID of video or audio

Returns:

  • (String, nil)

    when HTTP status code is 200

  • (String, nil)

    when other HTTP status code is returned. This String is HTTP response body itself.

See Also:



82
83
84
85
86
87
88
89
90
# File 'lib/line/bot/v2/messaging_api/api/messaging_api_blob_client.rb', line 82

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_message_content_preview(message_id:) ⇒ String?

Get a preview image of the image or video This requests to GET https://api-data.line.me/v2/bot/message/{messageId}/content/preview When you want to get HTTP status code or response headers, use #get_message_content_preview_with_http_info instead of this.

Parameters:

  • message_id (String)

    Message ID of image or video

Returns:

  • (String, nil)

    when HTTP status code is 200

  • (String, nil)

    when other HTTP status code is returned. This String is HTTP response body itself.

See Also:



126
127
128
129
130
131
132
133
134
# File 'lib/line/bot/v2/messaging_api/api/messaging_api_blob_client.rb', line 126

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

#get_message_content_preview_with_http_info(message_id:) ⇒ Array((String|nil), Integer, Hash{String => String})

Get a preview image of the image or video This requests to GET https://api-data.line.me/v2/bot/message/{messageId}/content/preview This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.

Parameters:

  • message_id (String)

    Message ID of image or video

Returns:

  • (Array((String|nil), Integer, Hash{String => String}))

    when HTTP status code is 200

  • (Array((String|nil), Integer, Hash{String => String}))

    when other HTTP status code is returned. String is HTTP response body itself.

See Also:



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/line/bot/v2/messaging_api/api/messaging_api_blob_client.rb', line 100

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_message_content_transcoding_by_message_id(message_id:) ⇒ Line::Bot::V2::MessagingApi::GetMessageContentTranscodingResponse, ...

Verify the preparation status of a video or audio for getting This requests to GET https://api-data.line.me/v2/bot/message/{messageId}/content/transcoding 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.

Parameters:

  • message_id (String)

    Message ID of video or audio

Returns:

See Also:



175
176
177
178
179
180
181
182
183
# File 'lib/line/bot/v2/messaging_api/api/messaging_api_blob_client.rb', line 175

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

#get_message_content_transcoding_by_message_id_with_http_info(message_id:) ⇒ Array(Line::Bot::V2::MessagingApi::GetMessageContentTranscodingResponse, Integer, Hash{String => String}), Array((String|nil), Integer, Hash{String => String})

Verify the preparation status of a video or audio for getting This requests to GET https://api-data.line.me/v2/bot/message/{messageId}/content/transcoding This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.

Parameters:

  • message_id (String)

    Message ID of video or audio

Returns:

See Also:



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/line/bot/v2/messaging_api/api/messaging_api_blob_client.rb', line 144

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

#get_message_content_with_http_info(message_id:) ⇒ Array((String|nil), Integer, Hash{String => String})

Download image, video, and audio data sent from users. This requests to GET https://api-data.line.me/v2/bot/message/{messageId}/content This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.

Parameters:

  • message_id (String)

    Message ID of video or audio

Returns:

  • (Array((String|nil), Integer, Hash{String => String}))

    when HTTP status code is 200

  • (Array((String|nil), Integer, Hash{String => String}))

    when other HTTP status code is returned. String is HTTP response body itself.

See Also:



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/line/bot/v2/messaging_api/api/messaging_api_blob_client.rb', line 56

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

#get_rich_menu_image(rich_menu_id:) ⇒ String?

Download rich menu image. This requests to GET https://api-data.line.me/v2/bot/richmenu/{richMenuId}/content When you want to get HTTP status code or response headers, use #get_rich_menu_image_with_http_info instead of this.

Parameters:

  • rich_menu_id (String)

    ID of the rich menu with the image to be downloaded

Returns:

  • (String, nil)

    when HTTP status code is 200

  • (String, nil)

    when other HTTP status code is returned. This String is HTTP response body itself.

See Also:



219
220
221
222
223
224
225
226
227
# File 'lib/line/bot/v2/messaging_api/api/messaging_api_blob_client.rb', line 219

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

#get_rich_menu_image_with_http_info(rich_menu_id:) ⇒ Array((String|nil), Integer, Hash{String => String})

Download rich menu image. This requests to GET https://api-data.line.me/v2/bot/richmenu/{richMenuId}/content This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.

Parameters:

  • rich_menu_id (String)

    ID of the rich menu with the image to be downloaded

Returns:

  • (Array((String|nil), Integer, Hash{String => String}))

    when HTTP status code is 200

  • (Array((String|nil), Integer, Hash{String => String}))

    when other HTTP status code is returned. String is HTTP response body itself.

See Also:



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/line/bot/v2/messaging_api/api/messaging_api_blob_client.rb', line 193

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

#set_rich_menu_image(rich_menu_id:, body: nil) ⇒ String?

Upload rich menu image This requests to POST https://api-data.line.me/v2/bot/richmenu/{richMenuId}/content When you want to get HTTP status code or response headers, use #set_rich_menu_image_with_http_info instead of this.

Parameters:

  • rich_menu_id (String)

    The ID of the rich menu to attach the image to

  • body (File, nil) (defaults to: nil)

Returns:

  • (String, nil)

    when HTTP status code is 200

  • (String, nil)

    when other HTTP status code is returned. This String is HTTP response body itself.

See Also:



267
268
269
270
271
272
273
274
275
276
277
# File 'lib/line/bot/v2/messaging_api/api/messaging_api_blob_client.rb', line 267

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

#set_rich_menu_image_with_http_info(rich_menu_id:, body: nil) ⇒ Array((String|nil), Integer, Hash{String => String})

Upload rich menu image This requests to POST https://api-data.line.me/v2/bot/richmenu/{richMenuId}/content This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.

Parameters:

  • rich_menu_id (String)

    The ID of the rich menu to attach the image to

  • body (File, nil) (defaults to: nil)

Returns:

  • (Array((String|nil), Integer, Hash{String => String}))

    when HTTP status code is 200

  • (Array((String|nil), Integer, Hash{String => String}))

    when other HTTP status code is returned. String is HTTP response body itself.

See Also:



238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# File 'lib/line/bot/v2/messaging_api/api/messaging_api_blob_client.rb', line 238

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