Skip to content

Commit

Permalink
Remove TONUpload class (xdevplatform#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
smaeda-ks committed Jun 18, 2019
1 parent 0febe01 commit c78ce8b
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 351 deletions.
1 change: 0 additions & 1 deletion lib/twitter-ads.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

require 'twitter-ads/http/request'
require 'twitter-ads/http/response'
require 'twitter-ads/http/ton_upload'

require 'twitter-ads/audiences/audience_intelligence'
require 'twitter-ads/audiences/tailored_audience'
Expand Down
97 changes: 0 additions & 97 deletions lib/twitter-ads/audiences/tailored_audience.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,9 @@ class TailoredAudience
'accounts/%{account_id}/tailored_audiences'.freeze # @api private
RESOURCE = "/#{TwitterAds::API_VERSION}/" +
'accounts/%{account_id}/tailored_audiences/%{id}'.freeze # @api private
RESOURCE_UPDATE = "/#{TwitterAds::API_VERSION}/" +
'accounts/%{account_id}/tailored_audience_changes'.freeze # @api private
RESOURCE_MEMBERSHIPS = "/#{TwitterAds::API_VERSION}/" +
'tailored_audience_memberships'.freeze # @api private
RESOURCE_USERS = "/#{TwitterAds::API_VERSION}/" +
'accounts/%{account_id}/tailored_audiences/' +
'%{id}/users'.freeze # @api private
# @api private
GLOBAL_OPT_OUT = "/#{TwitterAds::API_VERSION}/" +
'accounts/%{account_id}/tailored_audiences/global_opt_out'.freeze

LIST_TYPES = %w(
EMAIL
Expand Down Expand Up @@ -80,45 +73,6 @@ def create(account, name)
audience.from_response(response.body[:data])
end

# Updates the global opt-out list for the specified advertiser account.
#
# @example
# TailoredAudience.opt_out(account, '/path/to/file', 'EMAIL')
#
# @param account [Account] The account object instance.
# @param file_path [String] The path to the file to be uploaded.
# @param list_type [String] The tailored audience list type.
#
# @since 0.3.0
#
# @return [Boolean] The result of the opt-out update.
def opt_out(account, file_path, list_type)
upload = TwitterAds::TONUpload.new(account.client, file_path)
params = { input_file_path: upload.perform, list_type: list_type }
resource = GLOBAL_OPT_OUT % { account_id: account.id }
Request.new(account.client, :put, resource, params: params).perform
true
end

end

# Updates the current tailored audience instance.
#
# @example
# audience = account.tailored_audiences('xyz')
# audience.update('/path/to/file', 'EMAIL', 'REPLACE')
#
# @param file_path [String] The path to the file to be uploaded.
# @param list_type [String] The tailored audience list type.
# @param operation [String] The update operation type (Default: 'ADD').
#
# @since 0.3.0
#
# @return [TailoredAudience] [description]
def update(file_path, list_type, operation = 'ADD')
upload = TwitterAds::TONUpload.new(account.client, file_path)
update_audience(self, upload.perform, list_type, operation)
reload!
end

# Deletes the current tailored audience instance.
Expand All @@ -137,57 +91,6 @@ def delete!
from_response(response.body[:data])
end

# Returns the status of all changes for the current tailored audience instance.
#
# @example
# audience.status
#
# @since 0.3.0
#
# @return [Hash] Returns a hash object representing the tailored audience status.
def status
return nil unless id
resource = RESOURCE_UPDATE % { account_id: account.id }
request = Request.new(account.client, :get, resource, params: to_params)
Cursor.new(nil, request).to_a.select { |change| change[:tailored_audience_id] == id }
end

# This is a private API and requires whitelisting from Twitter.
#
# This real-time API will enable partners to upload batched tailored audience information
# to Twitter for processing in real-time
#
# @example
# TailoredAudience.memberships(
# account,
# [
# {
# "operation_type" => "Update",
# "params" => {
# "user_identifier" => "IUGKJHG-UGJHVHJ",
# "user_identifier_type" => "TAWEB_PARTNER_USER_ID",
# "audience_names" => "Recent Site Visitors, Recent Sign-ups",
# "advertiser_account_id" => "43853bhii879"
# }
# },
# ]
# )
#
# @return success_count, total_count
def self.memberships(account, params)
resource = RESOURCE_MEMBERSHIPS
headers = { 'Content-Type' => 'application/json' }
response = TwitterAds::Request.new(account.client,
:post,
resource,
headers: headers,
body: params.to_json).perform
success_count = response.body[:data][0][:success_count]
total_count = response.body[:request][0][:total_count]

[success_count, total_count]
end

# This is a private API and requires whitelisting from Twitter.
#
# This endpoint will allow partners to add, update and remove users from a given
Expand Down
156 changes: 0 additions & 156 deletions lib/twitter-ads/http/ton_upload.rb

This file was deleted.

1 change: 0 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
Dir['./spec/support/*.rb'].sort.each { |file| require file }

ADS_API = "https://ads-api.twitter.com/#{TwitterAds::API_VERSION}".freeze
TON_API = 'https://ton.twitter.com'.freeze
UPLOAD_API = 'https://upload.twitter.com/1.1'.freeze

RSpec.configure do |config|
Expand Down
96 changes: 0 additions & 96 deletions spec/twitter-ads/http/ton_upload_spec.rb

This file was deleted.

0 comments on commit c78ce8b

Please sign in to comment.