harvested2 5.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +3 -0
- data/.gitignore +35 -0
- data/.rspec +1 -0
- data/.rubocop.yml +34 -0
- data/.ruby-version +1 -0
- data/.travis.yml +12 -0
- data/Gemfile +20 -0
- data/HISTORY.md +118 -0
- data/MIT-LICENSE +21 -0
- data/README.md +66 -0
- data/Rakefile +24 -0
- data/harvested2.gemspec +30 -0
- data/lib/ext/array.rb +52 -0
- data/lib/ext/date.rb +9 -0
- data/lib/ext/hash.rb +17 -0
- data/lib/ext/time.rb +5 -0
- data/lib/harvest/account.rb +13 -0
- data/lib/harvest/api/account.rb +25 -0
- data/lib/harvest/api/base.rb +72 -0
- data/lib/harvest/api/clients.rb +10 -0
- data/lib/harvest/api/company.rb +12 -0
- data/lib/harvest/api/contacts.rb +9 -0
- data/lib/harvest/api/expense_categories.rb +9 -0
- data/lib/harvest/api/expenses.rb +26 -0
- data/lib/harvest/api/invoice_categories.rb +9 -0
- data/lib/harvest/api/invoice_messages.rb +86 -0
- data/lib/harvest/api/invoice_payments.rb +41 -0
- data/lib/harvest/api/invoices.rb +9 -0
- data/lib/harvest/api/projects.rb +9 -0
- data/lib/harvest/api/task_assignments.rb +75 -0
- data/lib/harvest/api/tasks.rb +9 -0
- data/lib/harvest/api/time_entry.rb +19 -0
- data/lib/harvest/api/user_assignments.rb +75 -0
- data/lib/harvest/api/users.rb +10 -0
- data/lib/harvest/base.rb +333 -0
- data/lib/harvest/behavior/activatable.rb +31 -0
- data/lib/harvest/behavior/crud.rb +80 -0
- data/lib/harvest/client.rb +23 -0
- data/lib/harvest/company.rb +8 -0
- data/lib/harvest/contact.rb +20 -0
- data/lib/harvest/credentials.rb +34 -0
- data/lib/harvest/errors.rb +27 -0
- data/lib/harvest/expense.rb +54 -0
- data/lib/harvest/expense_category.rb +10 -0
- data/lib/harvest/hardy_client.rb +80 -0
- data/lib/harvest/invoice.rb +75 -0
- data/lib/harvest/invoice_category.rb +8 -0
- data/lib/harvest/invoice_message.rb +8 -0
- data/lib/harvest/invoice_payment.rb +8 -0
- data/lib/harvest/line_item.rb +21 -0
- data/lib/harvest/model.rb +133 -0
- data/lib/harvest/project.rb +41 -0
- data/lib/harvest/receipt.rb +12 -0
- data/lib/harvest/task.rb +21 -0
- data/lib/harvest/task_assignment.rb +27 -0
- data/lib/harvest/time_entry.rb +57 -0
- data/lib/harvest/timezones.rb +130 -0
- data/lib/harvest/user.rb +58 -0
- data/lib/harvest/user_assignment.rb +27 -0
- data/lib/harvest/version.rb +3 -0
- data/lib/harvested2.rb +96 -0
- data/spec/factories/client.rb +14 -0
- data/spec/factories/contact.rb +8 -0
- data/spec/factories/expense.rb +10 -0
- data/spec/factories/expenses_category.rb +7 -0
- data/spec/factories/invoice.rb +25 -0
- data/spec/factories/invoice_category.rb +5 -0
- data/spec/factories/invoice_message.rb +9 -0
- data/spec/factories/invoice_payment.rb +7 -0
- data/spec/factories/line_item.rb +9 -0
- data/spec/factories/project.rb +15 -0
- data/spec/factories/task.rb +8 -0
- data/spec/factories/task_assignment.rb +8 -0
- data/spec/factories/time_entry.rb +13 -0
- data/spec/factories/user.rb +19 -0
- data/spec/factories/user_assigment.rb +7 -0
- data/spec/functional/clients_spec.rb +105 -0
- data/spec/functional/errors_spec.rb +42 -0
- data/spec/functional/expenses_spec.rb +97 -0
- data/spec/functional/invoice_messages_spec.rb +48 -0
- data/spec/functional/invoice_payments_spec.rb +51 -0
- data/spec/functional/invoice_spec.rb +138 -0
- data/spec/functional/project_spec.rb +76 -0
- data/spec/functional/tasks_spec.rb +119 -0
- data/spec/functional/time_entries_spec.rb +87 -0
- data/spec/functional/users_spec.rb +72 -0
- data/spec/harvest/base_spec.rb +10 -0
- data/spec/harvest/basic_auth_credentials_spec.rb +12 -0
- data/spec/harvest/expense_category_spec.rb +5 -0
- data/spec/harvest/expense_spec.rb +18 -0
- data/spec/harvest/invoice_message_spec.rb +5 -0
- data/spec/harvest/invoice_payment_spec.rb +5 -0
- data/spec/harvest/invoice_spec.rb +5 -0
- data/spec/harvest/oauth_credentials_spec.rb +11 -0
- data/spec/harvest/project_spec.rb +5 -0
- data/spec/harvest/task_assignment_spec.rb +5 -0
- data/spec/harvest/task_spec.rb +5 -0
- data/spec/harvest/time_entry_spec.rb +23 -0
- data/spec/harvest/user_assignment_spec.rb +5 -0
- data/spec/harvest/user_spec.rb +34 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/support/factory_bot.rb +5 -0
- data/spec/support/harvested_helpers.rb +28 -0
- data/spec/support/json_examples.rb +9 -0
- metadata +238 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
module Harvest
|
2
|
+
module API
|
3
|
+
class TimeEntry < Base
|
4
|
+
include Harvest::Behavior::Crud
|
5
|
+
|
6
|
+
api_model Harvest::TimeEntry
|
7
|
+
|
8
|
+
def stop(time_entry)
|
9
|
+
request(:put, credentials, "#{api_model.api_path}/#{time_entry.id}/stop")
|
10
|
+
time_entry.id
|
11
|
+
end
|
12
|
+
|
13
|
+
def restart(time_entry)
|
14
|
+
request(:put, credentials, "#{api_model.api_path}/#{time_entry.id}/restart")
|
15
|
+
time_entry.id
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module Harvest
|
2
|
+
module API
|
3
|
+
class UserAssignments < Base
|
4
|
+
api_model Harvest::UserAssignment
|
5
|
+
|
6
|
+
def all(project, query = {})
|
7
|
+
api_path = "/projects/#{project.id}/user_assignments"
|
8
|
+
response = request(:get, credentials, api_path, query: query)
|
9
|
+
response_parsed = api_model.to_json(response.parsed_response)
|
10
|
+
|
11
|
+
if response_parsed['total_pages'].to_i > 1
|
12
|
+
counter = response_parsed['page'].to_i
|
13
|
+
|
14
|
+
while counter <= response_parsed['total_pages'].to_i do
|
15
|
+
counter += 1
|
16
|
+
query = { 'page' => counter }
|
17
|
+
response_page = request(:get, credentials, api_path, query: query)
|
18
|
+
project_user_assignments = api_model.to_json(response.parsed_response)
|
19
|
+
response_parsed['user_assignments']
|
20
|
+
.concat(project_user_assignments['user_assignments'])
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
api_model.parse(response_parsed)
|
25
|
+
end
|
26
|
+
|
27
|
+
def find(project, user_assignment)
|
28
|
+
api_path = "/projects/#{project.id}/user_assignments/#{user_assignment.id}"
|
29
|
+
response = request(:get, credentials, api_path)
|
30
|
+
api_model.parse(response.parsed_response)
|
31
|
+
end
|
32
|
+
|
33
|
+
def create(project, user_assignment)
|
34
|
+
user_assignment = api_model.wrap(user_assignment)
|
35
|
+
api_path = "/projects/#{project.id}/user_assignments"
|
36
|
+
response = request(:post, credentials, api_path, body: user_assignment.to_json)
|
37
|
+
find(user_assignment.project_id, user_assignment.id)
|
38
|
+
end
|
39
|
+
|
40
|
+
def update(project, user_assignment)
|
41
|
+
user_assignment = api_model.wrap(user_assignment)
|
42
|
+
api_path = "/projects/#{project.id}/user_assignments/#{user_assignment.id}"
|
43
|
+
request(:put, credentials, api_path, body: user_assignment.to_json)
|
44
|
+
find(user_assignment.project_id, user_assignment.id)
|
45
|
+
end
|
46
|
+
|
47
|
+
def delete(user_assignment)
|
48
|
+
api_path = "/projects/#{project.id}/user_assignments/#{user_assignment.id}"
|
49
|
+
response = request(:delete, credentials, api_path)
|
50
|
+
user_assignment.id
|
51
|
+
end
|
52
|
+
|
53
|
+
def me(query = {})
|
54
|
+
api_path = "/user_assignments"
|
55
|
+
response = request(:get, credentials, api_path, query: query)
|
56
|
+
response_parsed = api_model.to_json(response.parsed_response)
|
57
|
+
|
58
|
+
if response_parsed['total_pages'].to_i > 1
|
59
|
+
counter = response_parsed['page'].to_i
|
60
|
+
|
61
|
+
while counter <= response_parsed['total_pages'].to_i do
|
62
|
+
counter += 1
|
63
|
+
query = { 'page' => counter }
|
64
|
+
response_page = request(:get, credentials, api_path, query: query)
|
65
|
+
user_assignments = api_model.to_json(response.parsed_response)
|
66
|
+
response_parsed['user_assignments']
|
67
|
+
.concat(user_assignments['user_assignments'])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
api_model.parse(response_parsed)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/lib/harvest/base.rb
ADDED
@@ -0,0 +1,333 @@
|
|
1
|
+
module Harvest
|
2
|
+
class Base
|
3
|
+
attr_reader :request, :credentials
|
4
|
+
# @see Harvest.client
|
5
|
+
# @see Harvest.hardy_client
|
6
|
+
def initialize(access_token: nil, account_id: nil, client_id: nil)
|
7
|
+
@credentials = if access_token && account_id
|
8
|
+
BasicAuthCredentials.new(access_token: access_token,
|
9
|
+
account_id: account_id)
|
10
|
+
elsif access_token
|
11
|
+
OAuthCredentials.new(access_token: access_token, client_id: client_id)
|
12
|
+
else
|
13
|
+
fail 'You must provide either :access_token and :account_id or an oauth :client_id'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# All API actions surrounding accounts
|
18
|
+
#
|
19
|
+
# == Examples
|
20
|
+
# harvest.account.rate_limit_status # Returns a Harvest::RateLimitStatus
|
21
|
+
#
|
22
|
+
# @return [Harvest::API::Account]
|
23
|
+
def account
|
24
|
+
@account ||= Harvest::API::Account.new(credentials)
|
25
|
+
end
|
26
|
+
|
27
|
+
# All API Actions surrounding Clients
|
28
|
+
#
|
29
|
+
# == Examples
|
30
|
+
# harvest.clients.all() # Returns all clients in the system
|
31
|
+
#
|
32
|
+
# harvest.clients.find(100) # Returns the client with id = 100
|
33
|
+
#
|
34
|
+
# client = Harvest::Client.new(:name => 'SuprCorp')
|
35
|
+
# saved_client = harvest.clients.create(client) # returns a saved version of Harvest::Client
|
36
|
+
#
|
37
|
+
# client = harvest.clients.find(205)
|
38
|
+
# client.name = 'SuprCorp LTD.'
|
39
|
+
# updated_client = harvest.clients.update(client) # returns an updated version of Harvest::Client
|
40
|
+
#
|
41
|
+
# client = harvest.clients.find(205)
|
42
|
+
# harvest.clients.delete(client) # returns 205
|
43
|
+
#
|
44
|
+
# client = harvest.clients.find(301)
|
45
|
+
# deactivated_client = harvest.clients.deactivate(client) # returns an updated deactivated client
|
46
|
+
# activated_client = harvest.clients.activate(client) # returns an updated activated client
|
47
|
+
#
|
48
|
+
# @see Harvest::Behavior::Crud
|
49
|
+
# @see Harvest::Behavior::Activatable
|
50
|
+
# @return [Harvest::API::Clients]
|
51
|
+
def clients
|
52
|
+
@clients ||= Harvest::API::Clients.new(credentials)
|
53
|
+
end
|
54
|
+
|
55
|
+
# All API Actions surrounding Client Contacts
|
56
|
+
#
|
57
|
+
# == Examples
|
58
|
+
# harvest.contacts.all() # Returns all contacts in the system
|
59
|
+
# harvest.contacts.all(10) # Returns all contacts for the client id=10 in the system
|
60
|
+
#
|
61
|
+
# harvest.contacts.find(100) # Returns the contact with id = 100
|
62
|
+
#
|
63
|
+
# contact = Harvest::Contact.new(:first_name => 'Jane', :last_name => 'Doe', :client_id => 10)
|
64
|
+
# saved_contact = harvest.contacts.create(contact) # returns a saved version of Harvest::Contact
|
65
|
+
#
|
66
|
+
# contact = harvest.contacts.find(205)
|
67
|
+
# contact.first_name = 'Jilly'
|
68
|
+
# updated_contact = harvest.contacts.update(contact) # returns an updated version of Harvest::Contact
|
69
|
+
#
|
70
|
+
# contact = harvest.contacts.find(205)
|
71
|
+
# harvest.contacts.delete(contact) # returns 205
|
72
|
+
#
|
73
|
+
# @see Harvest::Behavior::Crud
|
74
|
+
# @return [Harvest::API::Contacts]
|
75
|
+
def contacts
|
76
|
+
@contacts ||= Harvest::API::Contacts.new(credentials)
|
77
|
+
end
|
78
|
+
|
79
|
+
# All API Actions surrounding Projects
|
80
|
+
#
|
81
|
+
# == Examples
|
82
|
+
# harvest.projects.all() # Returns all projects in the system
|
83
|
+
#
|
84
|
+
# harvest.projects.find(100) # Returns the project with id = 100
|
85
|
+
#
|
86
|
+
# project = Harvest::Project.new(:name => 'SuprGlu' :client_id => 10)
|
87
|
+
# saved_project = harvest.projects.create(project) # returns a saved version of Harvest::Project
|
88
|
+
#
|
89
|
+
# project = harvest.projects.find(205)
|
90
|
+
# project.name = 'SuprSticky'
|
91
|
+
# updated_project = harvest.projects.update(project) # returns an updated version of Harvest::Project
|
92
|
+
#
|
93
|
+
# project = harvest.project.find(205)
|
94
|
+
# harvest.projects.delete(project) # returns 205
|
95
|
+
#
|
96
|
+
# project = harvest.projects.find(301)
|
97
|
+
# deactivated_project = harvest.projects.deactivate(project) # returns an updated deactivated project
|
98
|
+
# activated_project = harvest.projects.activate(project) # returns an updated activated project
|
99
|
+
#
|
100
|
+
# project = harvest.projects.find(401)
|
101
|
+
# harvest.projects.create_task(project, 'Bottling Glue') # creates and assigns a task to the project
|
102
|
+
#
|
103
|
+
# @see Harvest::Behavior::Crud
|
104
|
+
# @see Harvest::Behavior::Activatable
|
105
|
+
# @return [Harvest::API::Projects]
|
106
|
+
def projects
|
107
|
+
@projects ||= Harvest::API::Projects.new(credentials)
|
108
|
+
end
|
109
|
+
|
110
|
+
# All API Actions surrounding Tasks
|
111
|
+
#
|
112
|
+
# == Examples
|
113
|
+
# harvest.tasks.all() # Returns all tasks in the system
|
114
|
+
#
|
115
|
+
# harvest.tasks.find(100) # Returns the task with id = 100
|
116
|
+
#
|
117
|
+
# task = Harvest::Task.new(:name => 'Server Administration' :default => true)
|
118
|
+
# saved_task = harvest.tasks.create(task) # returns a saved version of Harvest::Task
|
119
|
+
#
|
120
|
+
# task = harvest.tasks.find(205)
|
121
|
+
# task.name = 'Server Administration'
|
122
|
+
# updated_task = harvest.tasks.update(task) # returns an updated version of Harvest::Task
|
123
|
+
#
|
124
|
+
# task = harvest.task.find(205)
|
125
|
+
# harvest.tasks.delete(task) # returns 205
|
126
|
+
#
|
127
|
+
# @see Harvest::Behavior::Crud
|
128
|
+
# @return [Harvest::API::Tasks]
|
129
|
+
def tasks
|
130
|
+
@tasks ||= Harvest::API::Tasks.new(credentials)
|
131
|
+
end
|
132
|
+
|
133
|
+
# All API Actions surrounding Users
|
134
|
+
#
|
135
|
+
# == Examples
|
136
|
+
# harvest.users.all() # Returns all users in the system
|
137
|
+
#
|
138
|
+
# harvest.users.find(100) # Returns the user with id = 100
|
139
|
+
#
|
140
|
+
# user = Harvest::User.new(:first_name => 'Edgar', :last_name => 'Ruth', :email => 'edgar@ruth.com', :password => 'mypassword', :timezone => :cst, :admin => false, :telephone => '444-4444')
|
141
|
+
# saved_user = harvest.users.create(user) # returns a saved version of Harvest::User
|
142
|
+
#
|
143
|
+
# user = harvest.users.find(205)
|
144
|
+
# user.email = 'edgar@ruth.com'
|
145
|
+
# updated_user = harvest.users.update(user) # returns an updated version of Harvest::User
|
146
|
+
#
|
147
|
+
# user = harvest.users.find(205)
|
148
|
+
# harvest.users.delete(user) # returns 205
|
149
|
+
#
|
150
|
+
# user = harvest.users.find(301)
|
151
|
+
# deactivated_user = harvest.users.deactivate(user) # returns an updated deactivated user
|
152
|
+
# activated_user = harvest.users.activate(user) # returns an updated activated user
|
153
|
+
#
|
154
|
+
# user = harvest.users.find(401)
|
155
|
+
# harvest.users.reset_password(user) # will trigger the reset password feature of harvest and shoot the user an email
|
156
|
+
#
|
157
|
+
# @see Harvest::Behavior::Crud
|
158
|
+
# @see Harvest::Behavior::Activatable
|
159
|
+
# @return [Harvest::API::Users]
|
160
|
+
def users
|
161
|
+
@users ||= Harvest::API::Users.new(credentials)
|
162
|
+
end
|
163
|
+
|
164
|
+
# All API Actions surrounding assigning tasks to projects
|
165
|
+
#
|
166
|
+
# == Examples
|
167
|
+
# project = harvest.projects.find(101)
|
168
|
+
# harvest.task_assignments.all(project) # returns all tasks assigned to the project (as Harvest::TaskAssignment)
|
169
|
+
#
|
170
|
+
# project = harvest.projects.find(201)
|
171
|
+
# harvest.task_assignments.find(project, 5) # returns the task assignment with ID 5 that is assigned to the project
|
172
|
+
#
|
173
|
+
# project = harvest.projects.find(301)
|
174
|
+
# task = harvest.tasks.find(100)
|
175
|
+
# assignment = Harvest::TaskAssignment.new(:task_id => task.id, :project_id => project.id)
|
176
|
+
# saved_assignment = harvest.task_assignments.create(assignment) # returns a saved version of the task assignment
|
177
|
+
#
|
178
|
+
# project = harvest.projects.find(401)
|
179
|
+
# assignment = harvest.task_assignments.find(project, 15)
|
180
|
+
# assignment.hourly_rate = 150
|
181
|
+
# updated_assignment = harvest.task_assignments.update(assignment) # returns an updated assignment
|
182
|
+
#
|
183
|
+
# project = harvest.projects.find(501)
|
184
|
+
# assignment = harvest.task_assignments.find(project, 25)
|
185
|
+
# harvest.task_assignments.delete(assignment) # returns 25
|
186
|
+
#
|
187
|
+
# @return [Harvest::API::TaskAssignments]
|
188
|
+
def task_assignments
|
189
|
+
@task_assignments ||= Harvest::API::TaskAssignments.new(credentials)
|
190
|
+
end
|
191
|
+
|
192
|
+
# All API Actions surrounding assigning users to projects
|
193
|
+
#
|
194
|
+
# == Examples
|
195
|
+
# project = harvest.projects.find(101)
|
196
|
+
# harvest.user_project_assignments.all(project) # returns all users assigned to the project (as Harvest::UserAssignment)
|
197
|
+
#
|
198
|
+
# project = harvest.projects.find(201)
|
199
|
+
# harvest.user_project_assignments.find(project, 5) # returns the user assignment with ID 5 that is assigned to the project
|
200
|
+
#
|
201
|
+
# project = harvest.projects.find(301)
|
202
|
+
# user = harvest.users.find(100)
|
203
|
+
# assignment = Harvest::UserAssignment.new(:user_id => user.id, :project_id => project.id)
|
204
|
+
# saved_assignment = harvest.user_project_assignments.create(assignment) # returns a saved version of the user assignment
|
205
|
+
#
|
206
|
+
# project = harvest.projects.find(401)
|
207
|
+
# assignment = harvest.user_project_assignments.find(project, 15)
|
208
|
+
# assignment.project_manager = true
|
209
|
+
# updated_assignment = harvest.user_project_assignments.update(assignment) # returns an updated assignment
|
210
|
+
#
|
211
|
+
# project = harvest.projects.find(501)
|
212
|
+
# assignment = harvest.user_project_assignments.find(project, 25)
|
213
|
+
# harvest.user_project_assignments.delete(assignment) # returns 25
|
214
|
+
#
|
215
|
+
# @return [Harvest::API::UserAssignments]
|
216
|
+
def user_assignments
|
217
|
+
@user_assignments ||= Harvest::API::UserAssignments.new(credentials)
|
218
|
+
end
|
219
|
+
|
220
|
+
# All API Actions surrounding managing expense categories
|
221
|
+
#
|
222
|
+
# == Examples
|
223
|
+
# harvest.expense_categories.all() # Returns all expense categories in the system
|
224
|
+
#
|
225
|
+
# harvest.expense_categories.find(100) # Returns the expense category with id = 100
|
226
|
+
#
|
227
|
+
# category = Harvest::ExpenseCategory.new(:name => 'Mileage', :unit_price => 0.485)
|
228
|
+
# saved_category = harvest.expense_categories.create(category) # returns a saved version of Harvest::ExpenseCategory
|
229
|
+
#
|
230
|
+
# category = harvest.clients.find(205)
|
231
|
+
# category.name = 'Travel'
|
232
|
+
# updated_category = harvest.expense_categories.update(category) # returns an updated version of Harvest::ExpenseCategory
|
233
|
+
#
|
234
|
+
# category = harvest.expense_categories.find(205)
|
235
|
+
# harvest.expense_categories.delete(category) # returns 205
|
236
|
+
#
|
237
|
+
# @see Harvest::Behavior::Crud
|
238
|
+
# @return [Harvest::API::ExpenseCategories]
|
239
|
+
def expense_categories
|
240
|
+
@expense_categories ||= Harvest::API::ExpenseCategories.new(credentials)
|
241
|
+
end
|
242
|
+
|
243
|
+
# All API Actions surrounding expenses
|
244
|
+
#
|
245
|
+
# == Examples
|
246
|
+
# harvest.expenses.all() # Returns all expenses for the current week
|
247
|
+
# harvest.expenses.all(Time.parse('11/12/2009')) # returns all expenses for the week of 11/12/2009
|
248
|
+
#
|
249
|
+
# harvest.expenses.find(100) # Returns the expense with id = 100
|
250
|
+
def expenses
|
251
|
+
@expenses ||= Harvest::API::Expenses.new(credentials)
|
252
|
+
end
|
253
|
+
|
254
|
+
def time_entries
|
255
|
+
@time_entries ||= Harvest::API::TimeEntry.new(credentials)
|
256
|
+
end
|
257
|
+
|
258
|
+
def reports
|
259
|
+
@reports ||= Harvest::API::Reports.new(credentials)
|
260
|
+
end
|
261
|
+
|
262
|
+
def invoice_categories
|
263
|
+
@invoice_categories ||= Harvest::API::InvoiceCategories.new(credentials)
|
264
|
+
end
|
265
|
+
|
266
|
+
def invoices
|
267
|
+
@invoices ||= Harvest::API::Invoices.new(credentials)
|
268
|
+
end
|
269
|
+
|
270
|
+
# All API Actions surrounding invoice payments
|
271
|
+
#
|
272
|
+
# == Examples
|
273
|
+
# invoice = harvest.invoices.find(100)
|
274
|
+
# harvest.invoice_payments.all(invoice) # returns all payments for the invoice (as Harvest::InvoicePayment)
|
275
|
+
#
|
276
|
+
# invoice = harvest.invoices.find(100)
|
277
|
+
# harvest.invoice_payments.find(invoice, 5) # returns the payment with ID 5 that is assigned to the invoice
|
278
|
+
#
|
279
|
+
# invoice = harvest.invoices.find(100)
|
280
|
+
# payment = Harvest::InvoicePayment.new(:invoice_id => invoice.id)
|
281
|
+
# saved_payment = harvest.invoice_payments.create(payment) # returns a saved version of the payment
|
282
|
+
#
|
283
|
+
# invoice = harvest.invoices.find(100)
|
284
|
+
# payment = harvest.invoice_payments.find(invoice, 5)
|
285
|
+
# harvest.invoice_payments.delete(payment) # returns 5
|
286
|
+
#
|
287
|
+
# @return [Harvest::API::InvoicePayments]
|
288
|
+
def invoice_payments
|
289
|
+
@invoice_payments ||= Harvest::API::InvoicePayments.new(credentials)
|
290
|
+
end
|
291
|
+
|
292
|
+
# id | integer | Unique ID for the message.
|
293
|
+
# sent_by | string | Name of the user that created the message.
|
294
|
+
# sent_by_email | string | Email of the user that created the message.
|
295
|
+
# sent_from | string | Name of the user that the message was sent from.
|
296
|
+
# sent_from_email | string | Email of the user that message was sent from.
|
297
|
+
# recipients | array | Array of invoice message recipients.
|
298
|
+
# subject | string | The message subject.
|
299
|
+
# body | string | The message body.
|
300
|
+
# include_link_to_client_invoice | boolean | Whether to include a link to the client invoice in the message body. Not used when thank_you is true.
|
301
|
+
# attach_pdf | boolean | Whether to attach the invoice PDF to the message email.
|
302
|
+
# send_me_a_copy | boolean | Whether to email a copy of the message to the current user.
|
303
|
+
# thank_you | boolean | Whether this is a thank you message.
|
304
|
+
# event_type | string | The type of invoice event that occurred with the message: send, close, draft, re-open, or view.
|
305
|
+
# reminder | boolean | Whether this is a reminder message.
|
306
|
+
# send_reminder_on | date | The date the reminder email will be sent.
|
307
|
+
# created_at | datetime | Date and time the message was created.
|
308
|
+
# updated_at | datetime | Date and time the message was last updated.
|
309
|
+
def invoice_messages
|
310
|
+
@invoice_messages ||= Harvest::API::InvoiceMessages.new(credentials)
|
311
|
+
end
|
312
|
+
|
313
|
+
# base_uri | string | The Harvest URL for the company.
|
314
|
+
# full_domain | string | The Harvest domain for the company.
|
315
|
+
# name | string | The name of the company.
|
316
|
+
# is_active | boolean | Whether the company is active or archived.
|
317
|
+
# week_start_day | string | The week day used as the start of the week. Returns one of: Saturday, Sunday, or Monday.
|
318
|
+
# wants_timestamp_timers | boolean | Whether time is tracked via duration or start and end times.
|
319
|
+
# time_format | string | The format used to display time in Harvest. Returns either decimal or hours_minutes.
|
320
|
+
# plan_type | string | The type of plan the company is on. Examples: trial, free, or simple-v4
|
321
|
+
# clock | string | Used to represent whether the company is using a 12-hour or 24-hour clock. Returns either 12h or 24h.
|
322
|
+
# decimal_symbol | string | Symbol used when formatting decimals.
|
323
|
+
# thousands_separator | string | Separator used when formatting numbers.
|
324
|
+
# color_scheme | string | The color scheme being used in the Harvest web client.
|
325
|
+
# expense_feature | boolean| Whether the expense module is enabled.
|
326
|
+
# invoice_feature | boolean | Whether the invoice module is enabled.
|
327
|
+
# estimate_feature | boolean | Whether the estimate module is enabled.
|
328
|
+
# approval_feature | boolean | Whether the approval module is enabled.
|
329
|
+
def company
|
330
|
+
@company ||= Harvest::API::Company.new(credentials)
|
331
|
+
end
|
332
|
+
end
|
333
|
+
end
|