appnexusapi 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +71 -39
- data/appnexusapi.gemspec +1 -2
- data/lib/appnexusapi.rb +21 -10
- data/lib/appnexusapi/configuration.rb +12 -0
- data/lib/appnexusapi/connection.rb +83 -90
- data/lib/appnexusapi/error.rb +3 -0
- data/lib/appnexusapi/faraday/raise_http_error.rb +15 -1
- data/lib/appnexusapi/read_only_service.rb +8 -0
- data/lib/appnexusapi/resource.rb +19 -15
- data/lib/appnexusapi/service.rb +35 -48
- data/lib/appnexusapi/services/ad_server_service.rb +9 -0
- data/lib/appnexusapi/{advertiser_service.rb → services/advertiser_service.rb} +0 -0
- data/lib/appnexusapi/{bidder_instance_service.rb → services/bidder_instance_service.rb} +0 -6
- data/lib/appnexusapi/{bidder_profile_service.rb → services/bidder_profile_service.rb} +0 -6
- data/lib/appnexusapi/{bidder_service.rb → services/bidder_service.rb} +0 -0
- data/lib/appnexusapi/services/brand_service.rb +2 -0
- data/lib/appnexusapi/services/browser_service.rb +2 -0
- data/lib/appnexusapi/{campaign_service.rb → services/campaign_service.rb} +0 -0
- data/lib/appnexusapi/services/category_service.rb +5 -0
- data/lib/appnexusapi/{content_category_service.rb → services/content_category_service.rb} +0 -1
- data/lib/appnexusapi/{creative_service.rb → services/creative_service.rb} +0 -0
- data/lib/appnexusapi/{creative_template_service.rb → services/creative_template_service.rb} +1 -6
- data/lib/appnexusapi/services/device_model_service.rb +2 -0
- data/lib/appnexusapi/{domain_list_service.rb → services/domain_list_service.rb} +0 -0
- data/lib/appnexusapi/services/inventory_attribute_service.rb +2 -0
- data/lib/appnexusapi/{inventory_source_service.rb → services/inventory_source_service.rb} +0 -0
- data/lib/appnexusapi/services/language_service.rb +2 -0
- data/lib/appnexusapi/{line_item_service.rb → services/line_item_service.rb} +0 -0
- data/lib/appnexusapi/services/log_level_data_download_service.rb +13 -0
- data/lib/appnexusapi/services/log_level_data_service.rb +105 -0
- data/lib/appnexusapi/services/media_type_service.rb +2 -0
- data/lib/appnexusapi/{member_service.rb → services/member_service.rb} +0 -0
- data/lib/appnexusapi/{object_limit_service.rb → services/object_limit_service.rb} +0 -0
- data/lib/appnexusapi/{operating_system_extended_service.rb → services/operating_system_extended_service.rb} +1 -6
- data/lib/appnexusapi/services/operating_system_service.rb +2 -0
- data/lib/appnexusapi/{payment_rule_service.rb → services/payment_rule_service.rb} +0 -0
- data/lib/appnexusapi/{placement_service.rb → services/placement_service.rb} +0 -0
- data/lib/appnexusapi/services/platform_member_service.rb +2 -0
- data/lib/appnexusapi/{profile_service.rb → services/profile_service.rb} +0 -0
- data/lib/appnexusapi/{publisher_service.rb → services/publisher_service.rb} +0 -0
- data/lib/appnexusapi/{segment_service.rb → services/segment_service.rb} +0 -2
- data/lib/appnexusapi/{site_service.rb → services/site_service.rb} +0 -0
- data/lib/appnexusapi/services/technical_attribute_service.rb +2 -0
- data/lib/appnexusapi/{tiny_tag_service.rb → services/tiny_tag_service.rb} +0 -6
- data/lib/appnexusapi/{user_service.rb → services/user_service.rb} +0 -0
- data/lib/appnexusapi/version.rb +1 -1
- data/spec/connection_spec.rb +46 -10
- data/spec/fixtures/vcr/content_category_crud.yml +188 -69
- data/spec/fixtures/vcr/log_level_data_service_download.yml +213 -0
- data/spec/integration/content_category_spec.rb +4 -0
- data/spec/{creative_service_spec.rb → integration/creative_service_spec.rb} +0 -0
- data/spec/integration/log_level_data_service_spec.rb +13 -0
- data/spec/{object_limit_service_spec.rb → integration/object_limit_service_spec.rb} +0 -0
- data/spec/integration/placement_spec.rb +0 -1
- data/spec/spec_helper.rb +2 -3
- metadata +52 -94
- data/lib/appnexusapi/ad_server_resource.rb +0 -2
- data/lib/appnexusapi/ad_server_service.rb +0 -20
- data/lib/appnexusapi/advertiser_resource.rb +0 -2
- data/lib/appnexusapi/bidder_instance_resource.rb +0 -2
- data/lib/appnexusapi/bidder_profile_resource.rb +0 -2
- data/lib/appnexusapi/bidder_resource.rb +0 -2
- data/lib/appnexusapi/brand_resource.rb +0 -2
- data/lib/appnexusapi/brand_service.rb +0 -8
- data/lib/appnexusapi/browser_resource.rb +0 -2
- data/lib/appnexusapi/browser_service.rb +0 -8
- data/lib/appnexusapi/campaign_resource.rb +0 -2
- data/lib/appnexusapi/category_resource.rb +0 -2
- data/lib/appnexusapi/category_service.rb +0 -12
- data/lib/appnexusapi/content_category_resource.rb +0 -2
- data/lib/appnexusapi/creative_resource.rb +0 -2
- data/lib/appnexusapi/creative_template_resource.rb +0 -2
- data/lib/appnexusapi/device_model_resource.rb +0 -2
- data/lib/appnexusapi/device_model_service.rb +0 -6
- data/lib/appnexusapi/domain_list_resource.rb +0 -2
- data/lib/appnexusapi/inventory_attribute_resource.rb +0 -2
- data/lib/appnexusapi/inventory_attribute_service.rb +0 -8
- data/lib/appnexusapi/inventory_source_resource.rb +0 -2
- data/lib/appnexusapi/language_resource.rb +0 -2
- data/lib/appnexusapi/language_service.rb +0 -8
- data/lib/appnexusapi/line_item_resource.rb +0 -2
- data/lib/appnexusapi/log_level_data_download_service.rb +0 -68
- data/lib/appnexusapi/log_level_data_resource.rb +0 -19
- data/lib/appnexusapi/log_level_data_service.rb +0 -26
- data/lib/appnexusapi/media_type_resource.rb +0 -2
- data/lib/appnexusapi/media_type_service.rb +0 -8
- data/lib/appnexusapi/member_resource.rb +0 -2
- data/lib/appnexusapi/object_limit_resource.rb +0 -2
- data/lib/appnexusapi/operating_system_extended_resource.rb +0 -2
- data/lib/appnexusapi/operating_system_resource.rb +0 -2
- data/lib/appnexusapi/operating_system_service.rb +0 -8
- data/lib/appnexusapi/payment_rule_resource.rb +0 -2
- data/lib/appnexusapi/placement_resource.rb +0 -2
- data/lib/appnexusapi/platform_member_resource.rb +0 -2
- data/lib/appnexusapi/platform_member_service.rb +0 -8
- data/lib/appnexusapi/profile_resource.rb +0 -2
- data/lib/appnexusapi/publisher_resource.rb +0 -2
- data/lib/appnexusapi/segment_resource.rb +0 -2
- data/lib/appnexusapi/site_resource.rb +0 -2
- data/lib/appnexusapi/technical_attribute_resource.rb +0 -2
- data/lib/appnexusapi/technical_attribute_service.rb +0 -8
- data/lib/appnexusapi/tiny_tag_resource.rb +0 -2
- data/lib/appnexusapi/user_resource.rb +0 -2
@@ -1,20 +0,0 @@
|
|
1
|
-
class AppnexusApi::AdServerService < AppnexusApi::Service
|
2
|
-
|
3
|
-
def initialize(connection)
|
4
|
-
@read_only = true
|
5
|
-
super(connection)
|
6
|
-
end
|
7
|
-
|
8
|
-
def name
|
9
|
-
"adserver"
|
10
|
-
end
|
11
|
-
|
12
|
-
def resource_class
|
13
|
-
ApnexusApi::AdServerResource
|
14
|
-
end
|
15
|
-
|
16
|
-
def uri_suffix
|
17
|
-
"ad-server"
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
class AppnexusApi::LogLevelDataDownloadService < AppnexusApi::Service
|
2
|
-
class BadChecksumException < Exception
|
3
|
-
end
|
4
|
-
|
5
|
-
def initialize(connection, options = {})
|
6
|
-
@read_only = true
|
7
|
-
@downloaded_files_path = options[:downloaded_files_path] || '.'
|
8
|
-
super(connection)
|
9
|
-
end
|
10
|
-
|
11
|
-
def download_location(params = {})
|
12
|
-
@connection.get(uri_suffix, params).headers['location']
|
13
|
-
end
|
14
|
-
|
15
|
-
# Parameter is a LogLevelDataResource
|
16
|
-
# Downloads a gzipped file
|
17
|
-
# Returns an array of paths to downloaded files
|
18
|
-
def download_resource(data_resource)
|
19
|
-
data_resource.download_params.map do |params|
|
20
|
-
uri = URI.parse(download_location(params.reject { |k,v| k == :checksum }))
|
21
|
-
filename = File.join(@downloaded_files_path, "#{params[:siphon_name]}_#{params[:hour]}_#{params[:split_part]}.gz")
|
22
|
-
Pester.retry_with_exponential_backoff do
|
23
|
-
download_file(uri, filename)
|
24
|
-
calculated_checksum = Digest::MD5.hexdigest(File.read(filename))
|
25
|
-
if calculated_checksum != params[:checksum]
|
26
|
-
error_message = "Calculated checksum of #{calculated_checksum} doesn't match API provided checksum #{params[:checksum]}"
|
27
|
-
puts error_message
|
28
|
-
fail(BadChecksumException, error_message)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
filename
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def get
|
37
|
-
fail(AppnexusApi::NotImplemented, 'This service is designed to work through download_location method.')
|
38
|
-
end
|
39
|
-
|
40
|
-
def uri_name
|
41
|
-
'siphon-download'
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
def download_file(uri, filename)
|
47
|
-
puts "Starting HTTP download for: #{uri.to_s}..."
|
48
|
-
http_object = Net::HTTP.new(uri.host, uri.port)
|
49
|
-
http_object.use_ssl = true if uri.scheme == 'https'
|
50
|
-
begin
|
51
|
-
http_object.start do |http|
|
52
|
-
request = Net::HTTP::Get.new(uri.request_uri)
|
53
|
-
http.read_timeout = 500
|
54
|
-
http.request(request) do |response|
|
55
|
-
open(filename, 'wb') do |io|
|
56
|
-
response.read_body do |chunk|
|
57
|
-
io.write(chunk)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
rescue StandardError => e
|
63
|
-
puts "=> Exception: '#{e}'. Skipping download."
|
64
|
-
return
|
65
|
-
end
|
66
|
-
puts "Stored download as #{filename}"
|
67
|
-
end
|
68
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
class AppnexusApi::LogLevelDataResource < AppnexusApi::Resource
|
2
|
-
# Extract an array of hashes of params to pass to the LogLevelDownloadService
|
3
|
-
def download_params
|
4
|
-
fail 'Missing necessaray information!' unless name && hour && timestamp && splits
|
5
|
-
|
6
|
-
splits.map do |split_part|
|
7
|
-
# In the case of regenerated files, there should be no checksum. These replaced hourly files should not be downloaded.
|
8
|
-
next nil if split_part['checksum'].blank?
|
9
|
-
|
10
|
-
{
|
11
|
-
split_part: split_part['part'],
|
12
|
-
siphon_name: name,
|
13
|
-
timestamp: timestamp,
|
14
|
-
hour: hour,
|
15
|
-
checksum: split_part['checksum']
|
16
|
-
}
|
17
|
-
end.compact
|
18
|
-
end
|
19
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
class AppnexusApi::LogLevelDataService < AppnexusApi::Service
|
2
|
-
def initialize(connection, options = {})
|
3
|
-
@read_only = true
|
4
|
-
@siphon_name = options[:siphon_name]
|
5
|
-
|
6
|
-
super(connection)
|
7
|
-
end
|
8
|
-
|
9
|
-
def since(time = nil)
|
10
|
-
params = {}
|
11
|
-
params[:siphon_name] = @siphon_name if @siphon_name
|
12
|
-
params[:updated_since] = time.strftime('%Y_%m_%d_%H') if time
|
13
|
-
|
14
|
-
# Anything with the same name and hour but with a newer timestamp is a republished replacement for an older file
|
15
|
-
# When this happens appnexus is supposed to set the checksum for the old file to null but they do not always
|
16
|
-
# actually do this.
|
17
|
-
siphons = get(params)
|
18
|
-
siphons.reject do |siphon|
|
19
|
-
(siphons - [siphon]).any? { |s| s.name == siphon.name && s.hour == siphon.hour && s.timestamp > siphon.timestamp }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def uri_name
|
24
|
-
'siphon'
|
25
|
-
end
|
26
|
-
end
|