Class: KlaviyoAPI::ProfileExclusion

Inherits:
Base
  • Object
show all
Extended by:
Support::Countable
Defined in:
lib/klaviyo_api/resources/profile_exclusion.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Support::Countable

count

Methods inherited from Base

activate_session, element_path, headers, reset_session, #to_h

Class Method Details

.collection_path(prefix_options = {}, query_options = {}) ⇒ Object


16
17
18
# File 'lib/klaviyo_api/resources/profile_exclusion.rb', line 16

def collection_path(prefix_options = {}, query_options = {})
  super prefix_options, query_options.deep_merge({ api_key: headers['api-key'] })
end

Instance Method Details

#createObject


21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/klaviyo_api/resources/profile_exclusion.rb', line 21

def create
  run_callbacks :create do
    # This endpoint does not accept JSON bodies.

    uri = Addressable::URI.new
    uri.query_values = attributes

    connection
      .post(self.class.collection_path,
            uri.query,
            self.class.headers.merge('Content-Type': 'application/x-www-form-urlencoded'))
      .tap(&method(:load_attributes_from_response))
  end
end