Class: Responsys::Api::Client
- Inherits:
-
Object
- Object
- Responsys::Api::Client
- Includes:
- All, Singleton
- Defined in:
- lib/responsys/api/client.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#credentials ⇒ Object
Returns the value of attribute credentials.
-
#header ⇒ Object
Returns the value of attribute header.
-
#jsession_id ⇒ Object
Returns the value of attribute jsession_id.
-
#session_id ⇒ Object
Returns the value of attribute session_id.
Instance Method Summary collapse
- #api_method(action, message = nil, response_type = :hash) ⇒ Object
- #available_operations ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
Methods included from Campaign
#check_failures, #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 Session
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
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/responsys/api/client.rb', line 16 def initialize settings = Responsys.configuration.settings @credentials = { username: settings[:username], password: settings[:password] } if settings[:debug] @client = Savon.client(wsdl: settings[:wsdl], element_form_default: :qualified, log_level: :debug, log: true, pretty_print_xml: true) else @client = Savon.client(wsdl: settings[:wsdl], element_form_default: :qualified) end login end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
14 15 16 |
# File 'lib/responsys/api/client.rb', line 14 def client @client end |
#credentials ⇒ Object
Returns the value of attribute credentials.
14 15 16 |
# File 'lib/responsys/api/client.rb', line 14 def credentials @credentials end |
#header ⇒ Object
Returns the value of attribute header.
14 15 16 |
# File 'lib/responsys/api/client.rb', line 14 def header @header end |
#jsession_id ⇒ Object
Returns the value of attribute jsession_id.
14 15 16 |
# File 'lib/responsys/api/client.rb', line 14 def jsession_id @jsession_id end |
#session_id ⇒ Object
Returns the value of attribute session_id.
14 15 16 |
# File 'lib/responsys/api/client.rb', line 14 def session_id @session_id end |
Instance Method Details
#api_method(action, message = nil, response_type = :hash) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/responsys/api/client.rb', line 32 def api_method(action, = nil, response_type = :hash) begin response = run_with_credentials(action, , jsession_id, header) 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 error_response = Responsys::Helper.format_response_with_errors(e) if error_response[:error][:code] == "INVALID_SESSION_ID" login api_method(action, , response_type) else error_response end end end |
#available_operations ⇒ Object
55 56 57 |
# File 'lib/responsys/api/client.rb', line 55 def available_operations @client.operations end |