Class: Hey::Subscriber

Inherits:
Dispatcher show all
Defined in:
lib/hey/subscriber.rb

Overview

Sends requests to the Yo API subscriber endpoint.

Instance Attribute Summary

Attributes inherited from Dispatcher

#api_token

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Dispatcher

#initialize

Constructor Details

This class inherits a constructor from Hey::Dispatcher

Class Method Details

.countObject

Sends a request to the subscribers_count endpoint using the API token set on the Hey module.



19
20
21
# File 'lib/hey/subscriber.rb', line 19

def self.count
  new.count
end

Instance Method Details

#countObject

Sends a request to the subscribers_count endpoint. Raises a MissingAPITokenError error if an API token hasn’t been set on the Hey module or Yo instance.



10
11
12
13
14
15
# File 'lib/hey/subscriber.rb', line 10

def count
  raise_for_missing_api_token!
  response = get 'subscribers_count'
  body = get_response_body response
  body['count']
end