Module: One::EmailDirect::Mixins::PublicationFacade
- Included in:
- Facade
- Defined in:
- lib/one/email_direct/mixins/publication.rb
Instance Method Summary collapse
-
#publication_add(credentials, name, description) ⇒ Object
Creates a new publication on the given EmailDirect account.
-
#publication_delete(credentials, publication_id) ⇒ Object
Deletes a publication on the given EmailDirect account.
-
#publication_get(credentials, name) ⇒ Hash
Returns the whole information of a publication on the given EmailDirect account.
-
#publication_getall(credentials) ⇒ Array
Returns all publications on the given EmailDirect account.
Instance Method Details
#publication_add(credentials, name, description) ⇒ Object
Creates a new publication on the given EmailDirect account.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/one/email_direct/mixins/publication.rb', line 11 def publication_add(credentials, name, description) response = send_soap( :publication_add, {:soap_action => 'http://espapi.net/v1/Publication_Add', :credentials => credentials, :publication_name => name, :publication_description => description} ) raise One::EmailDirect::EmailDirectException.new(response[:code], response[:message]) if response[:code] != '0' end |
#publication_delete(credentials, publication_id) ⇒ Object
Deletes a publication on the given EmailDirect account.
31 32 33 34 35 36 37 38 39 |
# File 'lib/one/email_direct/mixins/publication.rb', line 31 def publication_delete(credentials, publication_id) response = send_soap( :publication_delete, {:soap_action => 'http://espapi.net/v1/Publication_Delete', :credentials => credentials, :publication_id => publication_id} ) raise One::EmailDirect::EmailDirectException.new(response[:code], response[:message]) if response[:code] != '0' end |
#publication_get(credentials, name) ⇒ Hash
Returns the whole information of a publication on the given EmailDirect account.
51 52 53 54 |
# File 'lib/one/email_direct/mixins/publication.rb', line 51 def publication_get(credentials, name) publication_getall(credentials).each {|element| return element if element[:element_name] == name} nil end |
#publication_getall(credentials) ⇒ Array
Returns all publications on the given EmailDirect account.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/one/email_direct/mixins/publication.rb', line 67 def publication_getall(credentials) response = send_soap( :publication_get_all, {:soap_action => 'http://espapi.net/v1/Publication_GetAll', :credentials => credentials} ) # no elements were returned return [] if response.nil? # if it only has one element (Hash) you have to transform it to a single array element return [response[:element]] if response[:element].instance_of? Hash # more than 1 element if !block_given? elements = [] response[:element].each {|element| elements << element } elements else response[:element].each {|element| yield element } end end |