Class: Caren::Event

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

Overview

This class is just an intermediate for exporting events to Caren. It has the correct format for exports.

Instance Attribute Summary

Attributes inherited from Base

#attributes, #original_xml

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#as_xml, 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



28
29
30
# File 'lib/caren/event.rb', line 28

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

.array_rootObject



52
53
54
# File 'lib/caren/event.rb', line 52

def self.array_root
 :events
end

.charge_url(id = nil) ⇒ Object



60
61
62
# File 'lib/caren/event.rb', line 60

def self.charge_url id=nil
  "#{resource_location}/#{id}/charge"
end

.find(id, session) ⇒ Object



32
33
34
# File 'lib/caren/event.rb', line 32

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

.keysObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/caren/event.rb', line 5

def self.keys
  [ :id,                # Integer (Caren id, optional)
    :external_id,       # String Unique identifying string (Your event id)
    :name,              # String
    :comment,           # String
    :start,             # String (14:00)
    :duration,          # Integer
    :reservation,       # Integer
    :valid_from,        # Date
    :valid_to,          # Date
    :person_first_name, # String
    :charged,           # Boolean
    :person_last_name,  # String
    :person_male,       # Boolean
    :billable_id,       # Integer (Caren billable id)
    :billable_amount,   # Integer
    :cancel_before,     # DateTime
    :subject_id,        # Integer (Caren subject id)
    :external_person_id,# String (Your person id)
    :source             # String (remote_schedule,remote_realisation)
  ] + super
end

.node_rootObject



56
57
58
# File 'lib/caren/event.rb', line 56

def self.node_root
 :event
end

Instance Method Details

#charge(session) ⇒ Object



40
41
42
# File 'lib/caren/event.rb', line 40

def charge session
  self.class.from_xml session.post self.class.charge_url(self.id), self.to_xml
end

#create(session) ⇒ Object



36
37
38
# File 'lib/caren/event.rb', line 36

def create session
  self.class.from_xml session.post self.class.resource_url, self.to_xml
end

#delete(session) ⇒ Object



48
49
50
# File 'lib/caren/event.rb', line 48

def delete session
  session.delete self.class.resource_url(self.id)
end

#update(session) ⇒ Object



44
45
46
# File 'lib/caren/event.rb', line 44

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