Class: GetResponse::ConfirmationSubjectProxy
- Inherits:
-
Object
- Object
- GetResponse::ConfirmationSubjectProxy
- Includes:
- Conditions
- Defined in:
- lib/get_response/confirmation_subject_proxy.rb
Overview
Proxy class for confirmation subjects operations.
Instance Method Summary collapse
-
#all(conditions = {}) ⇒ Array
Get list of available subjects for confirmation messages.
-
#find(subject_id) ⇒ GetResponse::ConfirmationSubject
Get single confirmation subject based on its
id
. -
#initialize(connection) ⇒ ConfirmationSubjectProxy
constructor
A new instance of ConfirmationSubjectProxy.
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"})
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.
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 |