Module: KlaviyoAPI::Support::Countable

Included in:
Metric, Profile, ProfileExclusion
Defined in:
lib/klaviyo_api/resources/support/countable.rb

Instance Method Summary collapse

Instance Method Details

#count(params = {}) ⇒ Object


5
6
7
8
9
10
11
# File 'lib/klaviyo_api/resources/support/countable.rb', line 5

def count(params = {})
  all_params = params.deep_merge(params: { count: 1 })
  all(all_params).total
# klaviyo returns 400 if there are no results found in the account, so we catch it and return zero
rescue ActiveResource::BadRequest => e
  0
end