Class: Hubspot::Subscription

Inherits:
Object
  • Object
show all
Defined in:
lib/hubspot/subscription.rb

Constant Summary collapse

SUBSCRIPTIONS_PATH =
'/email/public/v1/subscriptions'
TIMELINE_PATH =
'/email/public/v1/subscriptions/timeline'
SUBSCRIPTION_PATH =
'/email/public/v1/subscriptions/:email_address'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response_hash) ⇒ Subscription

Returns a new instance of Subscription.



13
14
15
16
17
18
19
# File 'lib/hubspot/subscription.rb', line 13

def initialize(response_hash)
  @subscribed     = response_hash['subscribed']
  @marked_as_spam = response_hash['markedAsSpam']
  @bounced        = response_hash['bounced']
  @status         = response_hash['status']
  @subscription_statuses  = response_hash['SubscriptionStatuses']
end

Instance Attribute Details

#bouncedObject (readonly)

Returns the value of attribute bounced.



9
10
11
# File 'lib/hubspot/subscription.rb', line 9

def bounced
  @bounced
end

#marked_as_spamObject (readonly)

Returns the value of attribute marked_as_spam.



8
9
10
# File 'lib/hubspot/subscription.rb', line 8

def marked_as_spam
  @marked_as_spam
end

#statusObject (readonly)

Returns the value of attribute status.



10
11
12
# File 'lib/hubspot/subscription.rb', line 10

def status
  @status
end

#subscribedObject (readonly)

Returns the value of attribute subscribed.



7
8
9
# File 'lib/hubspot/subscription.rb', line 7

def subscribed
  @subscribed
end

#subscription_statusesObject (readonly)

Returns the value of attribute subscription_statuses.



11
12
13
# File 'lib/hubspot/subscription.rb', line 11

def subscription_statuses
  @subscription_statuses
end

Class Method Details

.status(email) ⇒ Object



22
23
24
25
# File 'lib/hubspot/subscription.rb', line 22

def status(email)
  response = Hubspot::Connection.get_json(SUBSCRIPTION_PATH, {email_address: email})
  new(response)
end

.unsubscribe_from_all_emails(email) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/hubspot/subscription.rb', line 27

def unsubscribe_from_all_emails(email)
  response =
    Hubspot::Connection.put_json(
      SUBSCRIPTION_PATH, params: { email_address: email },
                         body: { "unsubscribeFromAll": true }
    )
  new(response)
end