Class: GetResponse::ConfirmationSubjectProxy

Inherits:
Object
  • Object
show all
Includes:
Conditions
Defined in:
lib/get_response/confirmation_subject_proxy.rb

Overview

Proxy class for confirmation subjects operations.

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ ConfirmationSubjectProxy

Returns a new instance of ConfirmationSubjectProxy.



9
10
11
# File 'lib/get_response/confirmation_subject_proxy.rb', line 9

def initialize(connection)
  @connection = connection
end

Instance Method Details

#all(conditions = {}) ⇒ Array

Get list of available subjects for confirmation messages. They can be used in campaign settings. Example:

@proxy.all
@proxy.all(:language_code => {:equals => "pl"})

Parameters:

  • conditions (Hash) (defaults to: {})

    conditions passed to query, empty by default

Returns:

  • (Array)

    collection of ConfirmationSubject objects returned by API query



22
23
24
25
26
27
28
# File 'lib/get_response/confirmation_subject_proxy.rb', line 22

def all(conditions = {})
  conditions = parse_conditions(conditions)
  response = @connection.send_request("get_confirmation_subjects", conditions)["result"]
  response.inject([]) do |bodies, resp|
    bodies << ConfirmationSubject.new(resp[1].merge("id" => resp[0]))
  end
end

#find(subject_id) ⇒ GetResponse::ConfirmationSubject

Get single confirmation subject based on its id. Method can raise GetResposne::GetResponseError exception if no confirmation subject is found.

Parameters:

  • subject_id (String)

Returns:



36
37
38
39
40
41
42
# File 'lib/get_response/confirmation_subject_proxy.rb', line 36

def find(subject_id)
  params = {"confirmation_subject" => subject_id}
  resp = @connection.send_request("get_confirmation_subject", params)["result"]
  raise GetResponseError.new "Confirmation subject with id '#{subject_id}' not found." if resp.empty?
  subject_attrs = resp[subject_id.to_s].merge("id" => subject_id.to_s)
  ConfirmationSubject.new subject_attrs
end