Class: Blurb::ReportRequests
Constant Summary
collapse
- SD_TACTIC =
'T00020'.freeze
Constants inherited
from BaseClass
BaseClass::CAMPAIGN_TYPE_CODES
Instance Method Summary
collapse
#create_bulk, #delete, #list, #list_extended, #retrieve_extended, #update, #update_bulk
Constructor Details
#initialize(campaign_type:, base_url:, headers:) ⇒ ReportRequests
7
8
9
10
11
|
# File 'lib/blurb/report_requests.rb', line 7
def initialize(campaign_type:, base_url:, headers:)
@campaign_type = campaign_type
@base_url = "#{base_url}/v2/#{@campaign_type}"
=
end
|
Instance Method Details
#create(record_type:, report_date: Date.today, metrics: nil, segment: nil) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/blurb/report_requests.rb', line 13
def create(
record_type:,
report_date: Date.today,
metrics: nil,
segment: nil
)
metrics = get_default_metrics(record_type.to_s.underscore.to_sym, segment) if metrics.nil?
payload = {
metrics: metrics.map{ |m| m.to_s.camelize(:lower) }.join(","),
report_date: report_date
}
payload[:segment] = segment if segment
payload[:tactic] = SD_TACTIC if @campaign_type.to_sym == :sd
execute_request(
api_path: "/#{record_type.to_s.camelize(:lower)}/report",
request_type: :post,
payload: payload
)
end
|
#download(report_id) ⇒ Object
42
43
44
45
46
47
|
# File 'lib/blurb/report_requests.rb', line 42
def download(report_id)
execute_request(
api_path: "/reports/#{report_id}/download",
request_type: :get,
)
end
|
#retrieve(report_id) ⇒ Object
35
36
37
38
39
40
|
# File 'lib/blurb/report_requests.rb', line 35
def retrieve(report_id)
execute_request(
api_path: "/reports/#{report_id}",
request_type: :get,
)
end
|