Class: Shark::DoubleOptIn::Request

Inherits:
Base
  • Object
show all
Extended by:
Resource
Defined in:
lib/shark/double_opt_in/request.rb

Constant Summary collapse

ATTRIBUTES =
%w[
  payload
  request_type
  recipient
  subject
  header
  sub_header
  message
  verification_url
  verification_link_text
  message_footer_html
  timeout
  leeway_to_terminate
  max_verifications
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

add_datetime_accessors

Constructor Details

#initialize(data) ⇒ Request

Returns a new instance of Request.



38
39
40
41
42
# File 'lib/shark/double_opt_in/request.rb', line 38

def initialize(data)
  ATTRIBUTES.each do |key|
    public_send("#{key}=", data['attributes'][key])
  end
end

Class Method Details

.create(attributes) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/shark/double_opt_in/request.rb', line 26

def self.create(attributes)
  body = {
    data: {
      type: 'requests',
      attributes: attributes
    }
  }

  response = connection.request(:post, '/requests/', body: body)
  new(response.body['data'])
end