Class: Caren::CareProvider

Inherits:
Base
  • Object
show all
Defined in:
lib/caren/care_provider.rb

Overview

The CareProvider class enables the following features:

  • Update care provider settings

  • Get a list of care providers

  • Search for a specific care provider based on key/value

Instance Attribute Summary

Attributes inherited from Base

#attributes, #original_xml

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

from_xml, hash_from_image, init_dependent_objects, #initialize, #node_root, #resource_url, resource_url, search_url, #to_xml, to_xml

Constructor Details

This class inherits a constructor from Caren::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Caren::Base

Class Method Details

.all(session) ⇒ Object



47
48
49
# File 'lib/caren/care_provider.rb', line 47

def self.all session
  from_xml session.get(self.resource_url)
end

.array_rootObject



99
100
101
# File 'lib/caren/care_provider.rb', line 99

def self.array_root
  :care_providers
end

.find(id, session) ⇒ Object



43
44
45
# File 'lib/caren/care_provider.rb', line 43

def self.find id, session
  from_xml session.get(self.resource_url(id))
end

.keysObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/caren/care_provider.rb', line 7

def self.keys
  [ :id,                          # Integer (The id of this CP inside Caren)
    :name,                        # String
    :telephone,                   # String
    :website,                     # String
    :email,                       # String
    :address_line,                # String (Kerkstraat 1, 7522AH, Enschede)
    :logo,                        # String
    :url_shortcut,                # String
    :account_number,              # String
    :time_zone,                   # String (Amsterdam)
    :resolution,                  # String (exact,daypart,range)
    :bandwidth,                   # Integer (60 -> 60 minutes)
    :show_employee_names,         # Boolean
    :show_employee_photos,        # Boolean
    :employee_name_display_type,  # Integer (0 => Full name, 1 => Criminal name, 2 => First name)
    :custom_bulk_letter_template, # Text
    :max_start,                   # String (23:00)
    :min_start,                   # String (07:00)
    :show_employee_name_as_title, # Boolean
    :communication,               # Boolean
    :selective_communication,     # Boolean
    :api_key,                     # String, RSA public key
    :linkable,                    # Boolean
    :hidden,                      # Boolean
    :closed_beta,                 # Boolean
    :locale,                      # String
    :lat,
    :lng
  ] + super
end

.node_rootObject



103
104
105
# File 'lib/caren/care_provider.rb', line 103

def self.node_root
  :care_provider
end

.resource_locationObject



95
96
97
# File 'lib/caren/care_provider.rb', line 95

def self.resource_location
  "/api/pro/care_providers"
end

.search(key, value, session) ⇒ Object



39
40
41
# File 'lib/caren/care_provider.rb', line 39

def self.search key, value, session
  from_xml session.get( self.search_url(key,value) )
end

Instance Method Details

#as_xmlObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/caren/care_provider.rb', line 59

def as_xml
  { :name => self.name,
    :telephone => self.telephone,
    :website => self.website,
    :email => self.email,
    :address_line => self.address_line,
    :url_shortcut => self.url_shortcut,
    :time_zone => self.time_zone,
    :resolution => self.resolution,
    :bandwidth => self.bandwidth,
    :account_number => self.,
    :min_start => self.min_start,
    :max_start => self.max_start,
    :hidden => self.hidden,
    :employee_name_display_type => self.employee_name_display_type,
    :show_employee_name_as_title => self.show_employee_name_as_title,
    :show_employee_names => self.show_employee_names,
    :show_employee_photos => self.show_employee_photos,
    :communication => self.communication,
    :selective_communication => self.selective_communication,
    :api_key => self.api_key,
    :closed_beta => self.closed_beta,
    :locale => self.locale,
    :lat => self.lat,
    :lng => self.lng
  }
end

#to_logo_xml(logo_hash_or_path) ⇒ Object



87
88
89
90
91
92
93
# File 'lib/caren/care_provider.rb', line 87

def to_logo_xml logo_hash_or_path
  builder = Builder::XmlMarkup.new
   = self.class.hash_from_image(logo_hash_or_path)
  xml = builder.care_provider do |care_provider|
    care_provider.tag!("logo", Base64.encode64([:content]), "name" => [:name], "content-type" => [:content_type], "type" => "file" ) if 
  end
end

#update(session) ⇒ Object



51
52
53
# File 'lib/caren/care_provider.rb', line 51

def update session
  self.class.from_xml session.put(self.resource_url(self.id), self.to_xml)
end

#update_logo(logo_hash_or_path, session) ⇒ Object



55
56
57
# File 'lib/caren/care_provider.rb', line 55

def  logo_hash_or_path, session
  self.class.from_xml session.put(self.resource_url(self.id), self.to_logo_xml(logo_hash_or_path))
end