freshbooks 2.1 → 2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -0
- data/lib/freshbooks.rb +152 -1
- metadata +51 -44
data/Rakefile
CHANGED
@@ -7,6 +7,7 @@ require './lib/freshbooks.rb'
|
|
7
7
|
Hoe.new('freshbooks', FreshBooks::VERSION) do |p|
|
8
8
|
p.rubyforge_name = 'freshbooks'
|
9
9
|
p.author = 'Ben Vinegar'
|
10
|
+
p.email = 'ben@benlog.org'
|
10
11
|
# p.email = 'FIX'
|
11
12
|
# p.summary = 'FIX'
|
12
13
|
# p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
|
data/lib/freshbooks.rb
CHANGED
@@ -32,7 +32,7 @@ require 'rexml/document'
|
|
32
32
|
include REXML
|
33
33
|
|
34
34
|
module FreshBooks
|
35
|
-
VERSION = '2.
|
35
|
+
VERSION = '2.2' # Only works with 2.1
|
36
36
|
|
37
37
|
SERVICE_URL = "/api/#{VERSION}/xml-in"
|
38
38
|
|
@@ -485,5 +485,156 @@ module FreshBooks
|
|
485
485
|
end
|
486
486
|
|
487
487
|
end
|
488
|
+
|
489
|
+
Project = BaseObject.new(:project_id, :client_id, :name, :bill_method, :rate,
|
490
|
+
:description, :tasks)
|
491
|
+
|
492
|
+
class Project
|
493
|
+
TYPE_MAPPINGS = { 'project_id' => Fixnum, 'client_id' => Fixnum,
|
494
|
+
'rate' => Float, 'tasks' => Array
|
495
|
+
}
|
496
|
+
|
497
|
+
def initialize
|
498
|
+
super
|
499
|
+
self.tasks ||= []
|
500
|
+
end
|
501
|
+
|
502
|
+
def create
|
503
|
+
resp = FreshBooks::call_api('project.create', 'project' => self)
|
504
|
+
if resp.success?
|
505
|
+
self.project_id = resp.elements[1].text.to_i
|
506
|
+
end
|
507
|
+
|
508
|
+
resp.success? ? self.project_id : nil
|
509
|
+
end
|
510
|
+
|
511
|
+
def update
|
512
|
+
resp = FreshBooks::call_api('project.update', 'project' => self)
|
513
|
+
|
514
|
+
resp.success?
|
515
|
+
end
|
516
|
+
|
517
|
+
def self.get(project_id)
|
518
|
+
resp = FreshBooks::call_api('project.get', 'project_id' => project_id)
|
519
|
+
|
520
|
+
resp.success? ? self.new_from_xml(resp.elements[1]) : nil
|
521
|
+
end
|
522
|
+
|
523
|
+
def delete
|
524
|
+
Project::delete(self.project_id)
|
525
|
+
end
|
526
|
+
|
527
|
+
def self.delete(project_id)
|
528
|
+
resp = FreshBooks::call_api('project.delete', 'project_id' => project_id)
|
529
|
+
|
530
|
+
resp.success?
|
531
|
+
end
|
532
|
+
|
533
|
+
def self.list(options = {})
|
534
|
+
resp = FreshBooks::call_api('project.list', options)
|
535
|
+
|
536
|
+
return nil unless resp.success?
|
537
|
+
|
538
|
+
project_elems = resp.elements[1].elements
|
539
|
+
|
540
|
+
project_elems.map { |elem| self.new_from_xml(elem) }
|
541
|
+
end
|
542
|
+
end
|
543
|
+
|
544
|
+
Task = BaseObject.new(:task_id, :name, :billable, :rate, :description)
|
545
|
+
|
546
|
+
class Task
|
547
|
+
TYPE_MAPPINGS = { 'task_id' => Fixnum, 'rate' => Float }
|
548
|
+
|
549
|
+
def create
|
550
|
+
resp = FreshBooks::call_api('task.create', 'task' => self)
|
551
|
+
if resp.success?
|
552
|
+
self.task_id = resp.elements[1].text.to_i
|
553
|
+
end
|
554
|
+
|
555
|
+
resp.success? ? self.task_id : nil
|
556
|
+
end
|
557
|
+
|
558
|
+
def update
|
559
|
+
resp = FreshBooks::call_api('task.update', 'task' => self)
|
560
|
+
|
561
|
+
resp.success?
|
562
|
+
end
|
563
|
+
|
564
|
+
def self.get(task_id)
|
565
|
+
resp = FreshBooks::call_api('task.get', 'task_id' => task_id)
|
566
|
+
|
567
|
+
resp.success? ? self.new_from_xml(resp.elements[1]) : nil
|
568
|
+
end
|
569
|
+
|
570
|
+
def delete
|
571
|
+
Task::delete(self.task_id)
|
572
|
+
end
|
573
|
+
|
574
|
+
def self.delete(task_id)
|
575
|
+
resp = FreshBooks::call_api('task.delete', 'task_id' => task_id)
|
576
|
+
|
577
|
+
resp.success?
|
578
|
+
end
|
579
|
+
|
580
|
+
def self.list(options = {})
|
581
|
+
resp = FreshBooks::call_api('task.list', options)
|
582
|
+
|
583
|
+
return nil unless resp.success?
|
584
|
+
|
585
|
+
task_elems = resp.elements[1].elements
|
586
|
+
|
587
|
+
task_elems.map { |elem| self.new_from_xml(elem) }
|
588
|
+
end
|
589
|
+
end
|
590
|
+
|
591
|
+
TimeEntry = BaseObject.new(:time_entry_id, :project_id, :task_id, :hours,
|
592
|
+
:notes, :date)
|
593
|
+
|
594
|
+
class TimeEntry
|
595
|
+
TYPE_MAPPINGS = { 'time_entry_id' => Fixnum, 'project_id' => Fixnum,
|
596
|
+
'task_id' => Fixnum, 'hours' => Float }
|
597
|
+
|
598
|
+
def create
|
599
|
+
resp = FreshBooks::call_api('time_entry.create', 'time_entry' => self)
|
600
|
+
if resp.success?
|
601
|
+
self.time_entry_id = resp.elements[1].text.to_i
|
602
|
+
end
|
603
|
+
|
604
|
+
resp.success? ? self.time_entry_id : nil
|
605
|
+
end
|
606
|
+
|
607
|
+
def update
|
608
|
+
resp = FreshBooks::call_api('time_entry.update', 'time_entry' => self)
|
609
|
+
|
610
|
+
resp.success?
|
611
|
+
end
|
612
|
+
|
613
|
+
def self.get(time_entry_id)
|
614
|
+
resp = FreshBooks::call_api('time_entry.get', 'time_entry_id' => time_entry_id)
|
615
|
+
|
616
|
+
resp.success? ? self.new_from_xml(resp.elements[1]) : nil
|
617
|
+
end
|
618
|
+
|
619
|
+
def delete
|
620
|
+
TimeEntry::delete(self.time_entry_id)
|
621
|
+
end
|
622
|
+
|
623
|
+
def self.delete(time_entry_id)
|
624
|
+
resp = FreshBooks::call_api('time_entry.delete', 'time_entry_id' => time_entry_id)
|
625
|
+
|
626
|
+
resp.success?
|
627
|
+
end
|
628
|
+
|
629
|
+
def self.list(options = {})
|
630
|
+
resp = FreshBooks::call_api('time_entry.list', options)
|
631
|
+
|
632
|
+
return nil unless resp.success?
|
633
|
+
|
634
|
+
time_entry_elems = resp.elements[1].elements
|
635
|
+
|
636
|
+
time_entry_elems.map { |elem| self.new_from_xml(elem) }
|
637
|
+
end
|
638
|
+
end
|
488
639
|
end
|
489
640
|
|
metadata
CHANGED
@@ -1,33 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.0
|
3
|
-
specification_version: 1
|
4
2
|
name: freshbooks
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "2.
|
7
|
-
date: 2008-02-24 00:00:00 -05:00
|
8
|
-
summary: The author was too lazy to write a summary
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: ryand-ruby@zenspider.com
|
12
|
-
homepage: http://www.zenspider.com/ZSS/Products/freshbooks/
|
13
|
-
rubyforge_project: freshbooks
|
14
|
-
description: The author was too lazy to write a description
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: "2.2"
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Ben Vinegar
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-05-22 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hoe
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.5.1
|
23
|
+
version:
|
24
|
+
description: "FreshBooks.rb: FreshBooks API wrapper for Ruby"
|
25
|
+
email: ben@benlog.org
|
26
|
+
executables:
|
27
|
+
- freshbooks
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- History.txt
|
32
|
+
- Manifest.txt
|
33
|
+
- README.txt
|
31
34
|
files:
|
32
35
|
- History.txt
|
33
36
|
- Manifest.txt
|
@@ -36,28 +39,32 @@ files:
|
|
36
39
|
- bin/freshbooks
|
37
40
|
- lib/freshbooks.rb
|
38
41
|
- test/test_freshbooks.rb
|
39
|
-
|
40
|
-
|
42
|
+
has_rdoc: true
|
43
|
+
homepage: "FreshBooks.rb: FreshBooks API wrapper for Ruby"
|
44
|
+
post_install_message:
|
41
45
|
rdoc_options:
|
42
46
|
- --main
|
43
47
|
- README.txt
|
44
|
-
|
45
|
-
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
-
|
50
|
-
|
51
|
-
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "0"
|
55
|
+
version:
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: "0"
|
61
|
+
version:
|
52
62
|
requirements: []
|
53
63
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: 1.3.0
|
63
|
-
version:
|
64
|
+
rubyforge_project: freshbooks
|
65
|
+
rubygems_version: 1.0.1
|
66
|
+
signing_key:
|
67
|
+
specification_version: 2
|
68
|
+
summary: "FreshBooks.rb: FreshBooks API wrapper for Ruby"
|
69
|
+
test_files:
|
70
|
+
- test/test_freshbooks.rb
|