Method: Line::Bot::V2::MessagingApi::ApiClient#push_message_with_http_info

Defined in:
lib/line/bot/v2/messaging_api/api/messaging_api_client.rb

#push_message_with_http_info(push_message_request:, x_line_retry_key: nil) ⇒ Array(Line::Bot::V2::MessagingApi::PushMessageResponse, Integer, Hash{String => String}), ...

Sends a message to a user, group chat, or multi-person chat at any time. This requests to POST https://api.line.me/v2/bot/message/push This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.

Parameters:

  • push_message_request (PushMessageRequest)
  • x_line_retry_key (String, nil) (defaults to: nil)

    Retry key. Specifies the UUID in hexadecimal format (e.g., 123e4567-e89b-12d3-a456-426614174000) generated by any method. The retry key isn’t generated by LINE. Each developer must generate their own retry key.

Returns:

See Also:



2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
# File 'lib/line/bot/v2/messaging_api/api/messaging_api_client.rb', line 2774

def push_message_with_http_info( # steep:ignore MethodBodyTypeMismatch 
  push_message_request:, 
  x_line_retry_key: nil
)
  path = "/v2/bot/message/push"
  header_params = {
    "X-Line-Retry-Key": x_line_retry_key
  }.compact

  response = @http_client.post(
    path: path,
    body_params: push_message_request,
    headers: header_params
  )

  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::PushMessageResponse.create(json) # steep:ignore InsufficientKeywordArguments
    [response_body, 200, response.each_header.to_h]
  when 400
    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::ErrorResponse.create(json) # steep:ignore InsufficientKeywordArguments
    [response_body, 400, response.each_header.to_h]
  when 403
    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::ErrorResponse.create(json) # steep:ignore InsufficientKeywordArguments
    [response_body, 403, response.each_header.to_h]
  when 409
    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::ErrorResponse.create(json) # steep:ignore InsufficientKeywordArguments
    [response_body, 409, response.each_header.to_h]
  when 429
    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::ErrorResponse.create(json) # steep:ignore InsufficientKeywordArguments
    [response_body, 429, response.each_header.to_h]
  else
    [response.body, response.code.to_i, response.each_header.to_h]
  end
end