class Line::Bot::V2::Liff::ApiClient
Public Class Methods
Source
# File lib/line/bot/v2/liff/api/liff_client.rb, line 38 def initialize(base_url: nil, channel_access_token:, http_options: {}) @http_client = HttpClient.new( base_url: base_url || 'https://api.line.me', http_headers: { Authorization: "Bearer #{channel_access_token}" }, http_options: http_options ) end
Initializes a new {Line::Bot::V2::Liff::ApiClient} instance.
@param base_url [String] The base URL for requests (optional).
Defaults to 'https://api.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::Liff::ApiClient.new( channel_access_token: "YOUR_CHANNEL_ACCESS_TOKEN", http_options: { open_timeout: 5, read_timeout: 5, } )
Public Instance Methods
Source
# File lib/line/bot/v2/liff/api/liff_client.rb, line 95 def add_liff_app( add_liff_app_request: ) response_body, _status_code, _headers = add_liff_app_with_http_info( add_liff_app_request: add_liff_app_request ) response_body end
Adding the LIFF app to a channel This requests to POST https://api.line.me/liff/v1/apps
When you want to get HTTP status code or response headers, use {#add_liff_app_with_http_info} instead of this.
@param add_liff_app_request [AddLiffAppRequest] @see developers.line.biz/en/reference/liff-server/#add-liff-app @return [Line::Bot::V2::Liff::AddLiffAppResponse] when HTTP status code is 200 @return [String, nil] when HTTP status code is 400 @return [String, nil] when HTTP status code is 401 @return [String, nil] when other HTTP status code is returned. This String is HTTP response body itself.
Source
# File lib/line/bot/v2/liff/api/liff_client.rb, line 58 def add_liff_app_with_http_info( # steep:ignore MethodBodyTypeMismatch add_liff_app_request: ) path = "/liff/v1/apps" response = @http_client.post( path: path, body_params: add_liff_app_request, ) 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::Liff::AddLiffAppResponse.create(json) # steep:ignore InsufficientKeywordArguments [response_body, 200, response.each_header.to_h] when 400 [response.body, 400, response.each_header.to_h] when 401 [response.body, 401, response.each_header.to_h] else [response.body, response.code.to_i, response.each_header.to_h] end end
Adding the LIFF app to a channel This requests to POST https://api.line.me/liff/v1/apps
This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.
@param add_liff_app_request [AddLiffAppRequest] @see developers.line.biz/en/reference/liff-server/#add-liff-app @return [Array(Line::Bot::V2::Liff::AddLiffAppResponse
, Integer, Hash{String => String})] when HTTP status code is 200 @return [Array((String|nil), Integer, Hash{String => String})] when HTTP status code is 400 @return [Array((String|nil), Integer, Hash{String => String})] when HTTP status code is 401 @return [Array((String|nil), Integer, Hash{String => String})] when other HTTP status code is returned. String is HTTP response body itself.
Source
# File lib/line/bot/v2/liff/api/liff_client.rb, line 147 def delete_liff_app( liff_id: ) response_body, _status_code, _headers = delete_liff_app_with_http_info( liff_id: liff_id ) response_body end
Deletes a LIFF app from a channel. This requests to DELETE https://api.line.me/liff/v1/apps/{liffId}
When you want to get HTTP status code or response headers, use {#delete_liff_app_with_http_info} instead of this.
@param liff_id [String] ID of the LIFF app to be updated @see developers.line.biz/en/reference/liff-server/#delete-liff-app @return [String, nil] when HTTP status code is 200 @return [String, nil] when HTTP status code is 401 @return [String, nil] when HTTP status code is 404 @return [String, nil] when other HTTP status code is returned. This String is HTTP response body itself.
Source
# File lib/line/bot/v2/liff/api/liff_client.rb, line 115 def delete_liff_app_with_http_info( # steep:ignore MethodBodyTypeMismatch liff_id: ) path = "/liff/v1/apps/{liffId}" .gsub(/{liffId}/, liff_id.to_s) response = @http_client.delete( path: path, ) case response.code.to_i when 200 [response.body, 200, response.each_header.to_h] when 401 [response.body, 401, response.each_header.to_h] when 404 [response.body, 404, response.each_header.to_h] else [response.body, response.code.to_i, response.each_header.to_h] end end
Deletes a LIFF app from a channel. This requests to DELETE https://api.line.me/liff/v1/apps/{liffId}
This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.
@param liff_id [String] ID of the LIFF app to be updated @see developers.line.biz/en/reference/liff-server/#delete-liff-app @return [Array((String|nil), Integer, Hash{String => String})] when HTTP status code is 200 @return [Array((String|nil), Integer, Hash{String => String})] when HTTP status code is 401 @return [Array((String|nil), Integer, Hash{String => String})] when HTTP status code is 404 @return [Array((String|nil), Integer, Hash{String => String})] when other HTTP status code is returned. String is HTTP response body itself.
Source
# File lib/line/bot/v2/liff/api/liff_client.rb, line 200 def get_all_liff_apps( ) response_body, _status_code, _headers = get_all_liff_apps_with_http_info( ) response_body end
Gets information on all the LIFF apps added to the channel. This requests to GET https://api.line.me/liff/v1/apps
When you want to get HTTP status code or response headers, use {#get_all_liff_apps_with_http_info} instead of this.
@see developers.line.biz/en/reference/liff-server/#get-all-liff-apps @return [Line::Bot::V2::Liff::GetAllLiffAppsResponse] when HTTP status code is 200 @return [String, nil] when HTTP status code is 401 @return [String, nil] when HTTP status code is 404 @return [String, nil] when other HTTP status code is returned. This String is HTTP response body itself.
Source
# File lib/line/bot/v2/liff/api/liff_client.rb, line 166 def get_all_liff_apps_with_http_info( # steep:ignore MethodBodyTypeMismatch ) path = "/liff/v1/apps" 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::Liff::GetAllLiffAppsResponse.create(json) # steep:ignore InsufficientKeywordArguments [response_body, 200, response.each_header.to_h] when 401 [response.body, 401, response.each_header.to_h] when 404 [response.body, 404, response.each_header.to_h] else [response.body, response.code.to_i, response.each_header.to_h] end end
Gets information on all the LIFF apps added to the channel. This requests to GET https://api.line.me/liff/v1/apps
This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.
@see developers.line.biz/en/reference/liff-server/#get-all-liff-apps @return [Array(Line::Bot::V2::Liff::GetAllLiffAppsResponse
, Integer, Hash{String => String})] when HTTP status code is 200 @return [Array((String|nil), Integer, Hash{String => String})] when HTTP status code is 401 @return [Array((String|nil), Integer, Hash{String => String})] when HTTP status code is 404 @return [Array((String|nil), Integer, Hash{String => String})] when other HTTP status code is returned. String is HTTP response body itself.
Source
# File lib/line/bot/v2/liff/api/liff_client.rb, line 258 def update_liff_app( liff_id:, update_liff_app_request: ) response_body, _status_code, _headers = update_liff_app_with_http_info( liff_id: liff_id, update_liff_app_request: update_liff_app_request ) response_body end
Update LIFF app settings This requests to PUT https://api.line.me/liff/v1/apps/{liffId}
When you want to get HTTP status code or response headers, use {#update_liff_app_with_http_info} instead of this.
@param liff_id [String] ID of the LIFF app to be updated @param update_liff_app_request [UpdateLiffAppRequest] @see developers.line.biz/en/reference/liff-server/#update-liff-app @return [String, nil] when HTTP status code is 200 @return [String, nil] when HTTP status code is 400 @return [String, nil] when HTTP status code is 401 @return [String, nil] when HTTP status code is 404 @return [String, nil] when other HTTP status code is returned. This String is HTTP response body itself.
Source
# File lib/line/bot/v2/liff/api/liff_client.rb, line 220 def update_liff_app_with_http_info( # steep:ignore MethodBodyTypeMismatch liff_id:, update_liff_app_request: ) path = "/liff/v1/apps/{liffId}" .gsub(/{liffId}/, liff_id.to_s) response = @http_client.put( path: path, body_params: update_liff_app_request, ) case response.code.to_i when 200 [response.body, 200, response.each_header.to_h] when 400 [response.body, 400, response.each_header.to_h] when 401 [response.body, 401, response.each_header.to_h] when 404 [response.body, 404, response.each_header.to_h] else [response.body, response.code.to_i, response.each_header.to_h] end end
Update LIFF app settings This requests to PUT https://api.line.me/liff/v1/apps/{liffId}
This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.
@param liff_id [String] ID of the LIFF app to be updated @param update_liff_app_request [UpdateLiffAppRequest] @see developers.line.biz/en/reference/liff-server/#update-liff-app @return [Array((String|nil), Integer, Hash{String => String})] when HTTP status code is 200 @return [Array((String|nil), Integer, Hash{String => String})] when HTTP status code is 400 @return [Array((String|nil), Integer, Hash{String => String})] when HTTP status code is 401 @return [Array((String|nil), Integer, Hash{String => String})] when HTTP status code is 404 @return [Array((String|nil), Integer, Hash{String => String})] when other HTTP status code is returned. String is HTTP response body itself.