Class: ExtensisPortfolio::Connection
- Inherits:
-
Object
- Object
- ExtensisPortfolio::Connection
- Defined in:
- lib/extensis_portfolio/connection.rb
Instance Attribute Summary collapse
-
#http_client ⇒ Faraday::Connection
readonly
Returns a Faraday::Connection object for making http requests to the Extensis Portfolio API.
-
#session_id ⇒ String
readonly
Returns the session_id used to make calls to the Extensis Portfolio API.
-
#soap_client ⇒ Savon::Client
readonly
Returns a Savon::Client for making calls soap requests to the Extensis Portfolio API.
Instance Method Summary collapse
-
#get_asset_by_id(catalog_id, asset_id, result_options = {}) ⇒ Hash
Returns the asset that has the provided id.
-
#get_assets(catalog_id, query, result_options = {}) ⇒ Array
Returns a list of assets based on a query TODO: Simple method to get asset by id.
-
#get_catalogs ⇒ Array
Returns a list of catalogs.
-
#get_error_details_for_job(job_id) ⇒ Hash
Get the error details of a job.
-
#get_job_ids ⇒ Array
Returns a list of job ids.
-
#get_soap_operations ⇒ Array
Returns a list of available soap operations.
-
#get_status_for_jobs(job_ids) ⇒ Array
Get the status of jobs.
-
#initialize(server, username, password, options = {}) ⇒ Connection
constructor
Creates a new instance of ExtensisPortfolio::Connection.
-
#login(_username, _password) ⇒ Savon::Response
Logs in the soap client.
-
#logout ⇒ Object
Logs out the soap client, making the session id invalid.
Constructor Details
#initialize(server, username, password, options = {}) ⇒ Connection
Creates a new instance of ExtensisPortfolio::Connection
27 28 29 30 31 32 33 34 |
# File 'lib/extensis_portfolio/connection.rb', line 27 def initialize(server, username, password, = {}) @username = username @password = password = .merge(wsdl: "#{server}/ws/1.0/AssetService?wsdl") @soap_client = Savon.client() @http_client = Faraday.new(url: server) @session_id = get_session_id end |
Instance Attribute Details
#http_client ⇒ Faraday::Connection (readonly)
Returns a Faraday::Connection object for making http requests to the Extensis Portfolio API
14 15 16 |
# File 'lib/extensis_portfolio/connection.rb', line 14 def http_client @http_client end |
#session_id ⇒ String (readonly)
Returns the session_id used to make calls to the Extensis Portfolio API
8 9 10 |
# File 'lib/extensis_portfolio/connection.rb', line 8 def session_id @session_id end |
#soap_client ⇒ Savon::Client (readonly)
Returns a Savon::Client for making calls soap requests to the Extensis Portfolio API
20 21 22 |
# File 'lib/extensis_portfolio/connection.rb', line 20 def soap_client @soap_client end |
Instance Method Details
#get_asset_by_id(catalog_id, asset_id, result_options = {}) ⇒ Hash
Returns the asset that has the provided id
81 82 83 84 85 86 |
# File 'lib/extensis_portfolio/connection.rb', line 81 def get_asset_by_id(catalog_id, asset_id, = {}) query_term = ExtensisPortfolio::AssetQueryTerm.new('asset_id', 'equalValue', asset_id) query = ExtensisPortfolio::AssetQuery.new(query_term.to_hash) get_assets(catalog_id, query, ) end |
#get_assets(catalog_id, query, result_options = {}) ⇒ Array
Returns a list of assets based on a query TODO: Simple method to get asset by id
69 70 71 72 73 |
# File 'lib/extensis_portfolio/connection.rb', line 69 def get_assets(catalog_id, query, = {}) = { session_id: @session_id, catalog_id: catalog_id, assets: query.to_hash, result_options: } @soap_client.call(:get_assets, message: ).body[:get_assets_response][:return][:assets] end |
#get_catalogs ⇒ Array
Returns a list of catalogs
91 92 93 94 95 |
# File 'lib/extensis_portfolio/connection.rb', line 91 def get_catalogs = { session_id: @session_id } @soap_client.call(:get_catalogs, message: ).body[:get_catalogs_response][:return] end |
#get_error_details_for_job(job_id) ⇒ Hash
Get the error details of a job
120 121 122 123 |
# File 'lib/extensis_portfolio/connection.rb', line 120 def get_error_details_for_job(job_id) = { session_id: @session_id, job_id: job_id } @soap_client.call(:get_error_details_for_job, message: ).body[:get_error_details_for_job_response][:return] end |
#get_job_ids ⇒ Array
Returns a list of job ids
100 101 102 103 104 |
# File 'lib/extensis_portfolio/connection.rb', line 100 def get_job_ids = { session_id: @session_id } @soap_client.call(:get_job_i_ds, message: ).body[:get_job_i_ds_response][:return] end |
#get_soap_operations ⇒ Array
Returns a list of available soap operations
58 59 60 |
# File 'lib/extensis_portfolio/connection.rb', line 58 def get_soap_operations @soap_client.operations end |
#get_status_for_jobs(job_ids) ⇒ Array
Get the status of jobs
110 111 112 113 114 |
# File 'lib/extensis_portfolio/connection.rb', line 110 def get_status_for_jobs(job_ids) = { session_id: @session_id, job_ids: job_ids } @soap_client.call(:get_status_for_jobs, message: ).body[:get_status_for_jobs_response][:return] end |
#login(_username, _password) ⇒ Savon::Response
Logs in the soap client
41 42 43 44 45 |
# File 'lib/extensis_portfolio/connection.rb', line 41 def login(_username, _password) = { user_name: @username, encrypted_password: get_encrypted_password } @soap_client.call(:login, message: ) end |
#logout ⇒ Object
Logs out the soap client, making the session id invalid
49 50 51 52 53 |
# File 'lib/extensis_portfolio/connection.rb', line 49 def logout = { session_id: @session_id } @soap_client.call(:logout, message: ) end |