Class: Harvest::ResourceFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/harvest/resourcefactory.rb

Instance Method Summary collapse

Instance Method Details

#client(data) ⇒ Object



100
101
102
103
# File 'lib/harvest/resourcefactory.rb', line 100

def client(data)
  data ||= {}
  convert_dates(Struct::ResourceClient.new(data)) unless data.nil?
end

#company(data) ⇒ Object



22
23
24
25
# File 'lib/harvest/resourcefactory.rb', line 22

def company(data)
  data ||= {}
  Struct::Company.new(data)
end

#estimate(data) ⇒ Object



27
28
29
30
# File 'lib/harvest/resourcefactory.rb', line 27

def estimate(data)
  data ||= {}
  convert_estimate_line_items(convert_client(Struct::Estimate.new(data)))
end

#estimate_item_category(data) ⇒ Object



42
43
44
45
# File 'lib/harvest/resourcefactory.rb', line 42

def estimate_item_category(data)
  data ||= {}
  Struct::EstimateItemCategory.new(data)
end

#estimate_line_item(data) ⇒ Object



32
33
34
35
# File 'lib/harvest/resourcefactory.rb', line 32

def estimate_line_item(data)
  data ||= {}
  Struct::EstimateLineItem.new(data)
end

#estimate_message(data) ⇒ Object



37
38
39
40
# File 'lib/harvest/resourcefactory.rb', line 37

def estimate_message(data)
  data ||= {}
  Struct::EstimateMessage.new(data)
end

#expense(data) ⇒ Object



52
53
54
55
# File 'lib/harvest/resourcefactory.rb', line 52

def expense(data)
  data ||= {}
  Struct::Expense.new(data)
end

#expense_category(data) ⇒ Object



47
48
49
50
# File 'lib/harvest/resourcefactory.rb', line 47

def expense_category(data)
  data ||= {}
  Struct::ExpenseCategory.new(data)
end

#invoice(data) ⇒ Object



57
58
59
60
# File 'lib/harvest/resourcefactory.rb', line 57

def invoice(data)
  data ||= {}
  Struct::Invoice.new(data)
end

#invoice_item_category(data) ⇒ Object



77
78
79
80
# File 'lib/harvest/resourcefactory.rb', line 77

def invoice_item_category(data)
  data ||= {}
  Struct::InvoiceItemCategory.new(data)
end

#invoice_line_item(data) ⇒ Object



62
63
64
65
# File 'lib/harvest/resourcefactory.rb', line 62

def invoice_line_item(data)
  data ||= {}
  Struct::InvoiceLineItem.new(data)
end

#invoice_message(data) ⇒ Object



67
68
69
70
# File 'lib/harvest/resourcefactory.rb', line 67

def invoice_message(data)
  data ||= {}
  Struct::InvoiceMessage.new(data)
end

#invoice_payment(data) ⇒ Object



72
73
74
75
# File 'lib/harvest/resourcefactory.rb', line 72

def invoice_payment(data)
  data ||= {}
  Struct::InvoicePayment.new(data)
end

#message_recipient(data) ⇒ Object



17
18
19
20
# File 'lib/harvest/resourcefactory.rb', line 17

def message_recipient(data)
  data ||= {}
  Struct::MessageRecipient.new(data)
end

#project(data) ⇒ Object



95
96
97
98
# File 'lib/harvest/resourcefactory.rb', line 95

def project(data)
  data ||= {}
  convert_dates(Struct::Project.new(data)) unless data.nil?
end

#project_assignment(data) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/harvest/resourcefactory.rb', line 82

def project_assignment(data)
  data ||= {}
  unless data.nil?
    convert_dates(
      convert_project_client(
        convert_task_assignments(
          Struct::ProjectAssignment.new(data)
        )
      )
    )
  end
end

#resource(klass, data) ⇒ Object



12
13
14
15
# File 'lib/harvest/resourcefactory.rb', line 12

def resource(klass, data)
  data ||= {}
  send(klass.to_sym, data)
end

#task(data) ⇒ Object



110
111
112
113
# File 'lib/harvest/resourcefactory.rb', line 110

def task(data)
  data ||= {}
  convert_dates(Struct::Task.new(data)) unless data.nil?
end

#task_assignment(data) ⇒ Object



105
106
107
108
# File 'lib/harvest/resourcefactory.rb', line 105

def task_assignment(data)
  data ||= {}
  convert_dates(convert_task(Struct::TaskAssignment.new(data))) unless data.nil?
end

#time_entry(data) ⇒ Object



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/harvest/resourcefactory.rb', line 130

def time_entry(data)
  data ||= {}
  convert_dates(
    convert_project_client(
      convert_task_assignment(
        convert_task(
          convert_user_assignment(
            convert_user(
              convert_external_reference(
                Struct::TimeEntry.new(data)
              )
            )
          )
        )
      )
    )
  )
end

#time_entry_external_reference(data) ⇒ Object



125
126
127
128
# File 'lib/harvest/resourcefactory.rb', line 125

def time_entry_external_reference(data)
  data ||= {}
  Struct::TimeEntryExternalReference.new(data)
end

#user(data) ⇒ Object



115
116
117
118
# File 'lib/harvest/resourcefactory.rb', line 115

def user(data)
  data ||= {}
  convert_dates(Struct::User.new(data)) unless data.nil?
end

#user_assignment(data) ⇒ Object



120
121
122
123
# File 'lib/harvest/resourcefactory.rb', line 120

def user_assignment(data)
  data ||= {}
  convert_dates(Struct::UserAssignment.new(data)) unless data.nil?
end