Sha256: 58c5240f9cb94e813f18f1df9b5e8afa197df42e9d30fd75cd96348742c5268a
Contents?: true
Size: 1.28 KB
Versions: 6
Compression:
Stored size: 1.28 KB
Contents
require 'blurb/request_collection' class Blurb class HistoryRequest < RequestCollection FROM_DATE = (DateTime.now - 30).strftime('%Q') TO_DATE = DateTime.now.strftime('%Q') MAX_COUNT = 200.freeze MIN_COUNT = 50.freeze FILTERS = [] PARENT_CAMPAIGN_ID = nil def initialize(base_url:, headers:) @base_url = base_url @headers = headers end def retrieve( from_date: FROM_DATE, to_date: TO_DATE, campaign_ids:, filters: FILTERS, parent_campaign_id: PARENT_CAMPAIGN_ID, count: MAX_COUNT ) count = MIN_COUNT if count < MIN_COUNT count = MAX_COUNT if count > MAX_COUNT payload = { sort: { key: 'DATE', direction: 'ASC' }, fromDate: from_date.to_i, toDate: to_date.to_i, eventTypes: { CAMPAIGN: { eventTypeIds: campaign_ids } }, count: count } payload[:eventTypes][:CAMPAIGN].merge!({ filters: filters }) if filters.present? payload[:eventTypes][:CAMPAIGN].merge!({ parents: [{ campaignId: parent_campaign_id }] }) if parent_campaign_id.present? execute_request( api_path: "/history", request_type: :post, payload: payload ) end end end
Version data entries
6 entries across 6 versions & 1 rubygems