Class: Marketing::DataManager::Client
- Inherits:
-
Object
- Object
- Marketing::DataManager::Client
- Defined in:
- app/services/marketing/data_manager/client.rb
Overview
Shared REST transport for the Google Data Manager API: mints an OAuth access
token from a refresh token (no developer token, unlike the Google Ads API)
and POSTs/GETs the v1 endpoints. Subclassed by the audience
(CustomerMatch::Client) and conversion (EventsClient)
specializations, which add their ingest methods.
Credentials come from Heatwave::Configuration.fetch(:google_data_manager):
{ client_id:, client_secret:, refresh_token:, operating_account_id: }
where operating_account_id is the Google Ads customer id (digits only).
Direct Known Subclasses
Defined Under Namespace
Classes: ConfigurationError, Error
Constant Summary collapse
- OAUTH_TOKEN_URL =
Google OAuth2 token-exchange endpoint.
'https://oauth2.googleapis.com/token'- API_HOST =
Data Manager API host.
'https://datamanager.googleapis.com'- API_BASE =
Versioned API base path.
"#{API_HOST}/v1".freeze
- GOOGLE_ADS =
ProductAccount.accountType for Google Ads.
'GOOGLE_ADS'- HTTP_OPEN_TIMEOUT =
HTTP timeouts (seconds) so a hung Google connection can't stall a Sidekiq
worker — matches the codebase convention for OAuth API clients. 5- HTTP_TIMEOUT =
Read timeout (seconds) for Data Manager API calls.
30- REQUIRED_KEYS =
Required config keys.
%i[client_id client_secret refresh_token operating_account_id].freeze
Instance Method Summary collapse
-
#initialize(config: Heatwave::Configuration.fetch(:google_data_manager)) ⇒ Client
constructor
A new instance of Client.
-
#request_status(request_id) ⇒ Hash
RetrieveRequestStatusResponse.
Constructor Details
#initialize(config: Heatwave::Configuration.fetch(:google_data_manager)) ⇒ Client
Returns a new instance of Client.
44 45 46 47 48 49 |
# File 'app/services/marketing/data_manager/client.rb', line 44 def initialize(config: Heatwave::Configuration.fetch(:google_data_manager)) @config = (config || {}).symbolize_keys REQUIRED_KEYS.each do |key| raise ConfigurationError, "missing :google_data_manager #{key}" if @config[key].blank? end end |
Instance Method Details
#request_status(request_id) ⇒ Hash
Returns RetrieveRequestStatusResponse.
53 54 55 |
# File 'app/services/marketing/data_manager/client.rb', line 53 def request_status(request_id) get('/v1/requestStatus:retrieve', requestId: request_id) end |