Class: OfficeAutopilot::Client
- Inherits:
-
Object
- Object
- OfficeAutopilot::Client
show all
- Includes:
- Contacts
- Defined in:
- lib/office_autopilot/client.rb,
lib/office_autopilot/client/contacts.rb
Defined Under Namespace
Modules: Contacts
Constant Summary
Constants included
from Contacts
Contacts::CONTACTS_ENDPOINT
Instance Method Summary
collapse
Methods included from Contacts
#contacts_add, #contacts_search, #parse_contacts_xml, #xml_for_contact, #xml_for_search
Constructor Details
#initialize(options) ⇒ Client
Returns a new instance of Client.
13
14
15
16
17
18
19
20
21
|
# File 'lib/office_autopilot/client.rb', line 13
def initialize(options)
@api = {
:api_id => options[:api_id],
:api_key => options[:api_key]
}
raise ArgumentError, "Missing required parameter: api_id" if @api[:api_id].nil?
raise ArgumentError, "Missing required parameter: api_key" if @api[:api_key].nil?
end
|
Instance Method Details
#api_id ⇒ Object
23
24
25
|
# File 'lib/office_autopilot/client.rb', line 23
def api_id
@api[:api_id]
end
|
#api_key ⇒ Object
27
28
29
|
# File 'lib/office_autopilot/client.rb', line 27
def api_key
@api[:api_key]
end
|
#auth ⇒ Object
31
32
33
|
# File 'lib/office_autopilot/client.rb', line 31
def auth
{ 'Appid' => api_id, 'Key' => api_key }
end
|
#handle_response(response) ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'lib/office_autopilot/client.rb', line 39
def handle_response(response)
xml = Nokogiri::XML(response)
if xml.at_css('result').content =~ /failure/i
raise OfficeAutopilot::XmlError if xml.at_css('result error').content =~ /Invalid XML/i
end
response
end
|
#request(method, path, options) ⇒ Object
35
36
37
|
# File 'lib/office_autopilot/client.rb', line 35
def request(method, path, options)
handle_response( OfficeAutopilot::Request.send(method, path, options) )
end
|