Class: Line::Bot::V2::ManageAudience::ApiBlobClient

Inherits:
Object
  • Object
show all
Defined in:
lib/line/bot/v2/manage_audience/api/manage_audience_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::ManageAudience::ApiBlobClient instance.

Examples:

@client ||= Line::Bot::V2::ManageAudience::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/manage_audience/api/manage_audience_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

#add_user_ids_to_audience(file:, audience_group_id: nil, upload_description: nil) ⇒ String?

Add user IDs or Identifiers for Advertisers (IFAs) to an audience for uploading user IDs (by file). This requests to PUT https://api-data.line.me/v2/bot/audienceGroup/upload/byFile When you want to get HTTP status code or response headers, use #add_user_ids_to_audience_with_http_info instead of this.

Parameters:

  • file (File)

    A text file with one user ID or IFA entered per line. Specify text/plain as Content-Type. Max file number: 1 Max number: 1,500,000

  • audience_group_id (Integer, nil) (defaults to: nil)

    The audience ID.

  • upload_description (String, nil) (defaults to: nil)

    The description to register with the job

Returns:

  • (String, nil)

    when HTTP status code is 202

  • (String, nil)

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

See Also:



94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/line/bot/v2/manage_audience/api/manage_audience_blob_client.rb', line 94

def add_user_ids_to_audience(
  file:,
  audience_group_id: nil,
  upload_description: nil
)
  response_body, _status_code, _headers = add_user_ids_to_audience_with_http_info(
    file: file,
    audience_group_id: audience_group_id,
    upload_description: upload_description
  )

  response_body
end

#add_user_ids_to_audience_with_http_info(file:, audience_group_id: nil, upload_description: nil) ⇒ Array((String|nil), Integer, Hash{String => String})

Add user IDs or Identifiers for Advertisers (IFAs) to an audience for uploading user IDs (by file). This requests to PUT https://api-data.line.me/v2/bot/audienceGroup/upload/byFile This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.

Parameters:

  • file (File)

    A text file with one user ID or IFA entered per line. Specify text/plain as Content-Type. Max file number: 1 Max number: 1,500,000

  • audience_group_id (Integer, nil) (defaults to: nil)

    The audience ID.

  • upload_description (String, nil) (defaults to: nil)

    The description to register with the job

Returns:

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

    when HTTP status code is 202

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

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

See Also:



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/line/bot/v2/manage_audience/api/manage_audience_blob_client.rb', line 58

def add_user_ids_to_audience_with_http_info( # steep:ignore MethodBodyTypeMismatch 
  file:, 
  audience_group_id: nil, 
  upload_description: nil
)
  path = "/v2/bot/audienceGroup/upload/byFile"

  form_params = {
    "audienceGroupId": audience_group_id,
    "uploadDescription": upload_description,
    "file": file
  }.compact

  response = @http_client.put_form_multipart(
    path: path,
    form_params: form_params,
  )

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

#create_audience_for_uploading_user_ids(file:, description: nil, is_ifa_audience: nil, upload_description: nil) ⇒ Line::Bot::V2::ManageAudience::CreateAudienceGroupResponse, ...

Create audience for uploading user IDs (by file). This requests to POST https://api-data.line.me/v2/bot/audienceGroup/upload/byFile When you want to get HTTP status code or response headers, use #create_audience_for_uploading_user_ids_with_http_info instead of this.

Parameters:

  • file (File)

    A text file with one user ID or IFA entered per line. Specify text/plain as Content-Type. Max file number: 1 Max number: 1,500,000

  • description (String, nil) (defaults to: nil)

    The audience’s name. This is case-insensitive, meaning AUDIENCE and audience are considered identical. Max character limit: 120

  • is_ifa_audience (Boolean, nil) (defaults to: nil)

    To specify recipients by IFAs: set ‘true`. To specify recipients by user IDs: set `false` or omit isIfaAudience property.

  • upload_description (String, nil) (defaults to: nil)

    The description to register for the job (in ‘jobs[].description`).

Returns:

See Also:



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/line/bot/v2/manage_audience/api/manage_audience_blob_client.rb', line 163

def create_audience_for_uploading_user_ids(
  file:,
  description: nil,
  is_ifa_audience: nil,
  upload_description: nil
)
  response_body, _status_code, _headers = create_audience_for_uploading_user_ids_with_http_info(
    file: file,
    description: description,
    is_ifa_audience: is_ifa_audience,
    upload_description: upload_description
  )

  response_body
end

#create_audience_for_uploading_user_ids_with_http_info(file:, description: nil, is_ifa_audience: nil, upload_description: nil) ⇒ Array(Line::Bot::V2::ManageAudience::CreateAudienceGroupResponse, Integer, Hash{String => String}), Array((String|nil), Integer, Hash{String => String})

Create audience for uploading user IDs (by file). This requests to POST https://api-data.line.me/v2/bot/audienceGroup/upload/byFile This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.

Parameters:

  • file (File)

    A text file with one user ID or IFA entered per line. Specify text/plain as Content-Type. Max file number: 1 Max number: 1,500,000

  • description (String, nil) (defaults to: nil)

    The audience’s name. This is case-insensitive, meaning AUDIENCE and audience are considered identical. Max character limit: 120

  • is_ifa_audience (Boolean, nil) (defaults to: nil)

    To specify recipients by IFAs: set ‘true`. To specify recipients by user IDs: set `false` or omit isIfaAudience property.

  • upload_description (String, nil) (defaults to: nil)

    The description to register for the job (in ‘jobs[].description`).

Returns:

See Also:



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/line/bot/v2/manage_audience/api/manage_audience_blob_client.rb', line 119

def create_audience_for_uploading_user_ids_with_http_info( # steep:ignore MethodBodyTypeMismatch 
  file:, 
  description: nil, 
  is_ifa_audience: nil, 
  upload_description: nil
)
  path = "/v2/bot/audienceGroup/upload/byFile"

  form_params = {
    "description": description,
    "isIfaAudience": is_ifa_audience,
    "uploadDescription": upload_description,
    "file": file
  }.compact

  response = @http_client.post_form_multipart(
    path: path,
    form_params: form_params,
  )

  case response.code.to_i
  when 202
    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::ManageAudience::CreateAudienceGroupResponse.create(json) # steep:ignore InsufficientKeywordArguments
    [response_body, 202, response.each_header.to_h]
  else
    [response.body, response.code.to_i, response.each_header.to_h]
  end
end