Class: Responsys::Api::Client

Inherits:
Object
  • Object
show all
Includes:
All
Defined in:
lib/responsys/api/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Campaign

#check_failures, #trigger_custom_event, #trigger_message

Methods included from Table

#create_table, #create_table_with_pk, #delete_profile_extension_members, #delete_table, #delete_table_records, #merge_into_profile_extension, #merge_table_records, #merge_table_records_with_pk, #retrieve_profile_extension_records, #retrieve_table_records, #truncate_table

Methods included from List

#merge_list_members, #merge_list_members_riid, #retrieve_list_members

Methods included from Folder

#create_folder, #delete_folder, #folder_exists?, #list_folders

Methods included from Authentication

#logged_in?, #login, #logout

Instance Attribute Details

#clientObject

Returns the value of attribute client.



5
6
7
# File 'lib/responsys/api/client.rb', line 5

def client
  @client
end

Instance Method Details

#api_method(action, message = nil, response_type = :hash) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/responsys/api/client.rb', line 12

def api_method(action, message = nil, response_type = :hash)
  raise Responsys::Helper.get_message("api.client.api_method.wrong_action_#{action.to_s}") if action.to_sym == :login || action.to_sym == :logout

  SessionPool.instance.with do |session|
    begin
      session.
      response = session.run_with_credentials(action, message)
      case response_type
      when :result
        Responsys::Helper.format_response_result(response, action)
      when :hash
        Responsys::Helper.format_response_hash(response, action)
      end
    rescue Exception => e
      Responsys::Helper.format_response_with_errors(e)
    ensure
      session.logout
    end
  end
end

#available_operationsObject



33
34
35
36
37
# File 'lib/responsys/api/client.rb', line 33

def available_operations
  SessionPool.instance.with do |session|
    session.operations
  end
end