tedkulp-freshbooks.rb 3.0.19 → 3.0.20
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -2
- data/lib/freshbooks.rb +1 -1
- data/lib/freshbooks/base.rb +4 -0
- data/lib/freshbooks/connection.rb +5 -0
- data/lib/freshbooks/invoice.rb +4 -1
- data/lib/freshbooks/line.rb +1 -0
- data/test/test_base.rb +30 -0
- metadata +1 -1
data/README
CHANGED
data/lib/freshbooks.rb
CHANGED
@@ -60,7 +60,7 @@ require 'logger'
|
|
60
60
|
#
|
61
61
|
#==============================================================================
|
62
62
|
module FreshBooks
|
63
|
-
VERSION = '3.0.
|
63
|
+
VERSION = '3.0.20' # Gem version
|
64
64
|
API_VERSION = '2.1' # FreshBooks API version
|
65
65
|
SERVICE_URL = "/api/#{API_VERSION}/xml-in"
|
66
66
|
|
data/lib/freshbooks/base.rb
CHANGED
@@ -32,6 +32,11 @@ module FreshBooks
|
|
32
32
|
Response.new(result)
|
33
33
|
end
|
34
34
|
|
35
|
+
def direct_post(xml)
|
36
|
+
result = post(xml)
|
37
|
+
Response.new(result)
|
38
|
+
end
|
39
|
+
|
35
40
|
def start_session(&block)
|
36
41
|
@connection = obtain_connection if @start_session_count == 0
|
37
42
|
@start_session_count = @start_session_count + 1
|
data/lib/freshbooks/invoice.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
module FreshBooks
|
2
2
|
class Invoice < FreshBooks::Base
|
3
|
+
|
4
|
+
|
5
|
+
|
3
6
|
define_schema do |s|
|
4
7
|
s.fixnum :invoice_id, :client_id, :po_number
|
5
8
|
s.fixnum :recurring_id, :read_only => true
|
@@ -9,7 +12,7 @@ module FreshBooks
|
|
9
12
|
s.date_time :updated, :read_only => true
|
10
13
|
s.array :lines
|
11
14
|
s.object :links, :read_only => true
|
12
|
-
s.string :number, :organization, :status, :notes, :terms, :first_name, :last_name
|
15
|
+
s.string :number, :organization, :status, :notes, :terms, :first_name, :last_name, :currency_code
|
13
16
|
s.string :p_street1, :p_street2, :p_city, :p_state, :p_country, :p_code
|
14
17
|
s.string :return_uri
|
15
18
|
end
|
data/lib/freshbooks/line.rb
CHANGED
data/test/test_base.rb
CHANGED
@@ -66,6 +66,36 @@ class TestBase < Test::Unit::TestCase
|
|
66
66
|
assert xml_out.include?("<my_lines><my_line><description>description</description></my_line></my_lines>")
|
67
67
|
end
|
68
68
|
|
69
|
+
def test_create_objects_with_initializer_arguments
|
70
|
+
invoice_1 = FreshBooks::Invoice.new
|
71
|
+
invoice_1.client_id = 1
|
72
|
+
invoice_1.lines = [FreshBooks::Line.new, FreshBooks::Line.new]
|
73
|
+
invoice_1.lines[0].name = "Awesomeness"
|
74
|
+
invoice_1.lines[0].unit_cost = 9999
|
75
|
+
invoice_1.lines[0].quantity = 42
|
76
|
+
invoice_1.lines[1].name = "Ninja skills"
|
77
|
+
invoice_1.lines[1].unit_cost = 349
|
78
|
+
invoice_1.lines[1].quantity = 100
|
79
|
+
|
80
|
+
invoice_2 = FreshBooks::Invoice.new(
|
81
|
+
:client_id => 1,
|
82
|
+
:lines => [
|
83
|
+
FreshBooks::Line.new(
|
84
|
+
:name => "Awesomeness",
|
85
|
+
:unit_cost => 9999,
|
86
|
+
:quantity => 42
|
87
|
+
),
|
88
|
+
FreshBooks::Line.new(
|
89
|
+
:name => "Ninja skills",
|
90
|
+
:unit_cost => 349,
|
91
|
+
:quantity => 100
|
92
|
+
)
|
93
|
+
]
|
94
|
+
)
|
95
|
+
|
96
|
+
assert_equal invoice_1.to_xml, invoice_2.to_xml
|
97
|
+
end
|
98
|
+
|
69
99
|
end
|
70
100
|
|
71
101
|
module FreshBooks
|