Class: TeamdriveApi::Base
- Inherits:
-
Object
- Object
- TeamdriveApi::Base
- Includes:
- HTTParty
- Defined in:
- lib/teamdrive_api/base.rb
Overview
API-Baseclass for all XML RPC APIs
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(uri, api_checksum_salt, api_version) ⇒ Base
constructor
Create a new TD API Client.
-
#payload_for(command, query = {}) ⇒ Object
Generates the XML payload for the RPC.
Constructor Details
#initialize(uri, api_checksum_salt, api_version) ⇒ Base
Create a new TD API Client.
18 19 20 21 22 |
# File 'lib/teamdrive_api/base.rb', line 18 def initialize(uri, api_checksum_salt, api_version) @api_checksum_salt = api_checksum_salt @api_version = api_version @uri = uri.start_with?('http') ? uri : 'https://' + uri end |
Instance Attribute Details
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
9 10 11 |
# File 'lib/teamdrive_api/base.rb', line 9 def uri @uri end |
Instance Method Details
#payload_for(command, query = {}) ⇒ Object
Generates the XML payload for the RPC
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/teamdrive_api/base.rb', line 25 def payload_for(command, query = {}) out = header_for(command) query.each do |k, v| next if v.nil? v = v.to_s v = '$' + v if %w(true false).include?(v) out << "<#{k}>#{v}</#{k}>" end out << '</teamdrive>' end |