Class: Carddav::Client
- Inherits:
-
Object
- Object
- Carddav::Client
- Defined in:
- lib/carddav/client.rb
Constant Summary collapse
- NAMESPACES =
{ 'xmlns:D' => 'DAV:', 'xmlns:C' => 'urn:ietf:params:xml:ns:carddav' }
Instance Attribute Summary collapse
-
#addressbook_home_set_url ⇒ Object
Returns the value of attribute addressbook_home_set_url.
-
#addressbook_url ⇒ Object
Returns the value of attribute addressbook_url.
-
#current_user_principal_url ⇒ Object
Returns the value of attribute current_user_principal_url.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #cards ⇒ Object
-
#initialize(host, username, password) ⇒ Client
constructor
A new instance of Client.
Constructor Details
Instance Attribute Details
#addressbook_home_set_url ⇒ Object
Returns the value of attribute addressbook_home_set_url.
4 5 6 |
# File 'lib/carddav/client.rb', line 4 def addressbook_home_set_url @addressbook_home_set_url end |
#addressbook_url ⇒ Object
Returns the value of attribute addressbook_url.
4 5 6 |
# File 'lib/carddav/client.rb', line 4 def addressbook_url @addressbook_url end |
#current_user_principal_url ⇒ Object
Returns the value of attribute current_user_principal_url.
4 5 6 |
# File 'lib/carddav/client.rb', line 4 def current_user_principal_url @current_user_principal_url end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
4 5 6 |
# File 'lib/carddav/client.rb', line 4 def host @host end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
4 5 6 |
# File 'lib/carddav/client.rb', line 4 def password @password end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
4 5 6 |
# File 'lib/carddav/client.rb', line 4 def username @username end |
Instance Method Details
#cards ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/carddav/client.rb', line 39 def cards res = request addressbook_url, method: 'REPORT', depth: 1 do Nokogiri::XML::Builder.new do |xml| xml['C'].send 'addressbook-query', NAMESPACES do xml['D'].prop do xml['D'].getetag xml['C'].send 'address-data' end end end.to_xml end res.xpath('//address-data/text()').map { |node| Carddav::Card.new node } end |